Installing PHP 5 on IIS in 5 simple steps

Categories:

2. Set Your Environment Variables

For this step we'll need to use the Windows GUI, so rather than just write out all the steps I'll use images to do most of the talking.

  • Right click on the My Computer icon and select the properties menu item. You should be presented with a window as shown below in figure 1. Select the Advanced tab and then click the Environment Variables button at the bottom.


Figure 1

  • Scroll through the System variables list at the bottom until you come to the path variable. Select it and then click the edit button as shown below in figure 2.


figure 2

  • Move to the end of the text in the Variable value field and type in the path to the PHP directory you created earlier in step 1 (e.g. D:\PHP). Make sure that there is a semi colon (;) separating the new value you're entering and the previous one, and also place another semi colon (;) after as shown below in figure 3. Once you have added the path click on the ok button to save it and return to the previous window.


figure 3

  • This time we need to create a new environment variable. From the Environment Variables window click on the New button towards the bottom as shown below in figure 4.


figure 4

  • You should now see the New System Variable window as shown below in figure 5. In the Variable name field type in PHPRC, and in the Variable value field type in the path to your PHP install directory (e.g D:\PHP) as shown below. Once done click the ok button to create and save the variable. This PHPRC variable tells Windows where to look for your php.ini file, and if it doesn't find it there or if this variable is not set then IIS will look though your Windows system path.


figure 5

Comments

Anonymous's picture

Installing PEAR on PHP5

Thanks for answering my pervious post. I reinstalled PHP4 and used your IIS-AID, however that did not work.

Uninstalled it again. and Installed PHP5 per your instructions. Worked like charm. However, the software i want to install is called VTCalendar, http://vtcalendar.sourceforge.net/index.php, I followed the instructions but can not get it to work. It requires PEAR to be installed as well.

I'm assuming PEAR is out of the box ready in PHP5, do you have any resources in installing PEAR on my WIndows 2003 Server?

Thanks
Ricky

BeachBoy's picture

What's the best extensions to enable for PHP on IIS?

Dominic,

I'm curious about one thing regarding extensions for PHP 5.2.3 on Windows XP using IIS 5.1... Which extensions do you recommend that someone enable in their PHP.ini file for the best functionality for most PHP based applications? I plan to use Drupal 5.2 as mentioned in my previous post, as well as some other tools (CiviCRM, a OpenID server, etc...). If you could recommend some extensions (or write a article on the subject), it would be very helpful to me and others interested in using PHP 5. Also, please explain what the Pear libraries are used for, and where do we (I) download them, install them in PHP and so on.

Thanks in advance
~ BeachBoy

Brashquido's picture

@ Ricky Installing PEAR

@ Ricky

Installing PEAR should be as simple as opening up a command prompt, navigating to the root directory of your PHP install, and executing the go-pear.bat batch file. From there just answer the questions and you should be set.

@ BeachBoy

Enabling PHP extensions for IIS when using PHP as an ISAPI module is where things get a bit tricky, and you certainly do not want to go enabling PHP extensions unless there is a specific need. This is because a lot of PHP extensions are designed with the *nix multi process model in mind, where Windows/IIS uses a multi threaded model. This can cause major stability issues when using PHP extension that are not thread safe on Windows. Currently the only real viable way around this with PHP5 is to configure IIS to use PHP in CGI mode which is not effected by this, but this comes at the expense of a major performance hit (even using the new non thread safe binaries that significantly increase PHP CGI performance). If a PHP application requires a specific PHP extensions, then it will usually specify what one(s) it needs in its requirements documentation.

As for PEAR, have a read through the Wikipedia entry for more details. The PEAR package manager is included with the Windows distribution packages for PHP, and can be installed as per instructions above for Ricky. Again, if a web app requires a particular PEAR package, then that should be specified in the requirements documentation.
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

BeachBoy's picture

Woohoo! It works like a charm (so far)

Dominic,

Thanks for a very easy to follow install guide... I've now got my IIS Server setup for PHP, and I'm quite happy with the results. I don't know if anyone has mentioned this, but if you wish to use a PHP app that has an index.php file, you should set the Default Document section of the IIS manager to reflect this. Make sure you add it, then move it up the list before the iisstart.asp entry.

Regarding Pear, I'll be adding that as I need it. Now I'm off to test Drupal...

~Beach Boy

Anonymous's picture

Thaks for a great guide!!!

But i followed it to a tee. However when i pull up the http://localhost/phpinfo.php page it doesn't error out it just says done in the left corner of IE. It does nothing. Any Ideas? Thanks again for the detailed guide and any help you can offer.

Jason

Brashquido's picture

Ok, what version of windows

Ok, what version of windows are you using? Can you scan your IIS logs for phpinfo.php and post back the entire line if you find it?
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Great GUIDE!! Just facing one problem...

Hi Brashquido,

Thanks for the wonderful step-by-step guide. I'm still having a problem with the prompt that wants to download the file rather that run it. I've checked the MAPPING settings and they are correct. I also tried using:
http://localhost:8020/phpinfo.php BUT it wants to save the file. Other html files work fine though.

Any ideas?

Thanks

Anonymous's picture

PHP Code shows up in browser!!

Thanks for the great guide, but when I try the PHP test the code shows up instead of the page. It's like nothing gets processed.

I tried the small code you suggest and the same thing happens.

Thanks in advance

Anonymous's picture

Great Guide!!

Thank you very much!! This has been my 5th attempt at configuring IIS and PHP. After all the rubbish advice from the first search results in google, i hit the next button about 15 time and found your site! Thank goodness!!

Again, many thanks for the advice!

Damien

Brashquido's picture

If you are being prompted to

If you are being prompted to download php files rather than them being processed, then I'll stongly suspect that it is your application mapping. I know you said you've check it, but it is the only way I've ever been able to reproduce this problem. Double and triple check this, and if the problem continues feel free to send me a private message or use the website contact form to get in contact me as if the application mapping is not the issue I am as keen to find a resolution as you are.

As for php code being displayed in the browser window rather than being processed, then double check that your php code is enclosed in the proper php tags. Your php scripts may also be configure to use short tags, and if so you'll need to enable the short tag option in php.ini or modifiy your scripts to use the full php tags.

Thanks for the kudos Damien, glad to know the guide helped :)
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster