## Installing PHP 5 on IIS in 5 simple steps

Categories:

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

If you get "the specified CGI application misbehaved" then you must use php5isapi.dll INSTEAD OF php.exe %s %S.

Spent couple of hours but fixed it. Please amend you article, if applicable.

### Nice work, glad you got it

Nice work, glad you got it working. However, it is possible to get phpMyAdmin working with PHP CGI. If you are using PHP CGI and receive error messages such as you've described then it is likely that the CGI related directives in php.ini needed tweaking for Windows/IIS. Out of interest, what instructions did you follow that advised to use "php.exe %s %S"? If you were using PHP5, the PHP CGI executable is php-cgi.exe .

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

### Thanks

Thanks, your tutorial above is kick ass.. do you have tutorial step by step similar like above, but this one to install MySQL on IIS 5.1 to work with PHP 5.

Thank you before and I really appreciate it.

### Glad the tutorial was of

Glad the tutorial was of some help. You can find a tutorial on how to install and configure MySQL 5 on Windows in the How To Guides section.
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

500 is an internal server
Brashquido | Tue, 2007-11-20 14:31

Well i have no spaces put in the filenames or in the link

Added php to the path variable and also "phprc" too

Pecl extension i hav only mysql one enabled. Have done it according to the instruction you gave above and was working fine with all php pages until i restarted the system. After that am getting http 500 error. Dont knw y it is coming nw.

pls help

Was this your first attempt at installing PHP? Have you changed anything on your system since your last reboot? Are there any events in the event log that might shed some light
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

as you said i have disabled the friendly http error and then i got this message "%1 is not a valid Win32 application. " will that help you to trobleshoot.

### What exactly have you set

What exactly have you set for your PHP application mapping? With PHP5 your application mapping should be either;
For CGI
X:\path\to\php\php-cgi.exe

For ISAPI
X:\path\to\php\php5isapi.dll

The only other way to map PHP for IIS is using FastCGI, but in most cases you'll be using one of the two above. If you have anything other than exactly what I've listed above (change the path to suite your environment) then PHP will not work.
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

### C:\path\to\php\php5isapi.dll

Have Done it according to the instructions given above in your list...and have set up the php5isapi.dll
in Home directory -> configuration.... but no web extension is done as mine is iis 5.

### I'm running out of ideas.

I'm running out of ideas. The "%1 is not a valid Win32 application." error you are getting indicates several possibilities;

1) There are spaces in the application mapping path.

2) The application mapping extension is different from the actual scripts you are trying to run.E.g, the application mapping is .php3 and the actual scripts are .php.

3) The path to the actual php5isapi is wrong in your application mapping.

Apart from those I'm actually not too sure what else it could be off the top of my head. One question; as your using IIS 5, are you using URLScan or IIS Lockdown at all? If so, is PHP blocked in there at all?
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster