PHP & Microsoft IIS

I am setting up my workstation so I can do some web development where I work. The only web servers they use are Microsoft Internet Information Servers so I’m setting up my Windowss XP system with both Apache (personal testing) and IIS 5.1. My first task is to revamp the work order system we use, which is written in ASP, to make it more user friendly and intuitive. I am also trying out a free web based help desk called OpenIT because it has all the functionality we want (trouble tickets, inventory, knowledge base, etc.). No reason to reinvent the wheel. :)

The trouble I had started while trying to install PHP 5.0.4 on IIS. I did the manual installation because that’s just want I’m used to and setup OpenIT in a virtual directory (that’s how it will be on the server). I followed the usual steps for manually installing PHP on IIS (ISAPI module) but nothing seemed to be working. I created a PHP info file and put it in the directory where OpenIT installed. When I’d try to open it in IE or Firefox, it would just give me a printout of what was in the file so obviously PHP wasn’t parsing correctly.

In case you are wondering, the PHP info file will tell you what version of PHP you are running, the environmental variables and what extensions are enabled. If you want to find out what you are running on your web host (if it’s not yourself), create a file called phpdata.php and edit it with a text editor. Add the following line:

< ? phpinfo() ?>

Save the file and upload it to your web host. Now, just open the file (http://www.yourdomain.com/phpdata.php) and you will get a report of what your PHP configuration is on that server.

Back to the topic at hand, I continued checking the configuration and it all seemed correct. I even read back through the IIS manual installation instructions and it was all correct. The doc_root section of my PHP.ini file pointed to the default IIS root directory (c:\inetpub\wwwroot) but I thought I’d try commenting it out because I was using a virtual directory. Sure enough, it worked perfectly. Why? I don’t know but everything seems to be working fine so far.

So, if you are having trouble with PHP & IIS, and your PHP files are in a virtual directory, try commenting out the doc_root line in your PHP.ini file. Comment out the line by putting a semi-colon (;) in front of the line. Other than that, all the other instructions for installing PHP with IIS 5 should be followed.

Only those who will risk going too far can possibly find out how far one can go. – T. S. Eliot

13.Oct.05 Technology


You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

6 Responses to “PHP & Microsoft IIS”

  1. Rollie |

    I felt like an idiot installing PHP on IIS myself. I kept doing manual installs and never did figure out what was wrong. When I tried an automated install, it was fine.

    Glad I wasn’t the only one. :)

  2. wyckedone |

    The problem is that the manual installation instructions tell you to set the doc_root line, in the php.ini file, to point to “c:\inetpub\wwwroot” for IIS. It did work if I put all my PHP files into the wwwroot directory, or a directory located there, but it doesn’t work for virtual directories. The PHP files in the virtual directory didn’t get parsed correctly until after I commented out the doc_root line in php.ini.

  3. alligatorbob |

    ugh! i was banging my head against the wall for a couple hours. i am/was using virtual directies and couldn’t get phpinfo() to run for the life of me. that’s what i get for following the instructions. commenting out the doc_root did the trick. thanks for the post.

  4. wyckedone |

    You’re welcome. :smile:

  5. Panos |

    Yes, but the problem is that still IIS or PHP won’t provide the proper doc_root for scripts running under virtual directories.

  6. wyckedone |

    All the scripts are working fine. I have 4 different PHP based sites running in virtual directories (not in the wwwroot) and haven’t had a problem. From what I’ve read, leaving doc_root empty is only a problem if you have PHP running in Safe Mode.

Leave a Reply