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

This doesn't work.

This doesn't work.

Brashquido's picture

What version of PHP?

For PHP 5.2.x these install instructions certainly do work, however as per any installation instructions an assumption is made of a clean target environment as there is no way any install guide can account for all variations of system configurations out there. If you are using PHP 5.3.x this guide won't help you (as noted in bold on the first page). If using PHP 5.2.x then I suggest you clean off your system and try again. Also make sure you are using the threadsafe version of PHP for use with this guide.

----------------
Dominic Ryan
6 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

php5isapi.dll problem

I get stuck into 2 problems.

1. php5isapi.dll is missing (i can't find this dll in the php pakage C:\PHP )

2. When i reach this step:

" In the Extension field enter .php and then click on the browse button in the top right and select the php5isapi.dll file from inside you PHP installation directory (e.g D:\PHP). The default is to accept all verbs, but if you wish you can limit the verbs to tighten security for you PHP application mapping. Ensure that the Script engine and Check that file exists options as ticked and then press ok until you exit the properties windows. "

...the ok button is disabled, that means i can not press ok to add an application extension mapping.

any solution for this?

i must mention that i use windows xp sp3, iis 5.1 i think and PHP 5.2.14

Brashquido's picture

For PHP ISAPI you must NOT use the NTS version

If you are using PHP 5.2.14 and you are unable to find the php5isapi.dll file anywhere in your extracted PHP files, then you have downloaded the non thread safe version of PHP. To use ISAPI you MUST download the thread safe version, i.e. this one. This will also probably be the cause of your second issue as you cannot add an application mapping without specifying a DLL or executable file to handle the mapping that you are making. Also make sure you are logged on with Administrative permissions. Be sure to delete all your PHP files before switching from the non thread safe binaries to the thread safe binaries. These binaries are not interchangable, and if you get them mixed up then PHP/IIS will start crashing.

----------------
Dominic Ryan
6 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Running phpinfo.php displays the contents of phpinfo.php

Hi Ryan,

This is a strange problem after I installed PHP following the steps you mentioned in the article. When I run the URL: http://localhost/php/phpinfo.php, it shows the contents of the phpinfo.php file in the browser:

<?php
phpinfo
();
?>

Any idea why does it happen?

Thanks
Shobhit Sinha

Anonymous's picture

HTTP 500 error

The above worked by adding .php in Mappings. I could see the PHP configuration page. But suddenly after sometime, it started giving HTTP 500 error when phpinfo.php was accessed.

I checked your previous post and tried that fastcgi.impersonate = 0; does not solves the problem.

Please help.

Thanks

Shobhit Sinha

Brashquido's picture

Look at the trouble shooting guides

Hi Shobhit,

There are quite a few configuration items that can cause HTTP 500 errors, so my advice would be to first have a read through my trouble shooting guide for PHP HTTP 500 errors as well as all the comments.

----------------
Dominic Ryan
6 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Great Article

Hi Ryan,

I could resolve the HTTP 500 issue by simply following the steps in your article once again. Everything worked out just nicely thereafter.

Thanks
Shobhit Sinha

Anonymous's picture

thanks

after a lot of search and step by step in many web site this is the only one where i find the good and best solution tahnks a lot

Anonymous's picture

CGI error or the PHP test file propmts for download

Hi.. I am new to all this.. used IIS 5.1 and installed the PHP.. however i could not find this in the package..
"php5isapi.dll"... trying to map it to all the different .exe files(php-cgi.exe, php.exe) either will result in CGI time out error for which i have already set the timeout option as found on net.. or it prompts for download of the info file.. can't seem to get around this... just downloaded the 'php5isapi.dll' hope mapping to this works...
thanks..