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

Brashquido's picture

PHP 5.2.10 or 5.3

Are sure you downloaded PHP 5.2.10? I've just had a look and php5isapi.dll is there. As of PHP 5.3 (which is currently in RC stage) phpisapi.dll will be dropped, so it is possible you've downloaded that one instead. If not, try downloading PHP 5.2.10 again.

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

Anonymous's picture

Best PHP install guide!

This is easily the best installation guide I've found - better detail and background than others I've seen. I had an old PHP/apache installation, and using some other tutorials got into real trouble...

I used the uninstall PHP guide from this site, then used this guide to do a fresh install. I confess I was wary of using custom .vbs scripts on the uninstall but they worked perfectly.

Thanks for sharing your knowledge!

Richard

Anonymous's picture

RY

Getting to environment variables is a little different in XP. You need to go to Start > Control Panel > System, instead of right-clicking My Computer.

Brashquido's picture

XP environment variables

You can still get to your environment variables in XP using the method described in the guide. However you can also use the method you described, which also works for Windows 2003 Server. There is always more than one way to skin a cat with IT :)

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

Anonymous's picture

Environment Variables

Do not put the PHP path directly at the end if you have MySQL paths also.

The following post is in response to PHP crashing when mysqli_fetch_assoc() is executed:

http://marc.info/?l=php-internals&m=123825270214607&w=2

Reprinted below:

Put the PHP directory first in your path, doing so will make the mysql extensions use the php's libmysql.

Anonymous's picture

Dialog box to open/save file

Well darn. Its a great read and easy follow, but I am having issues. I have added mappings at the Server level and the Default Website level for

Extension: .php
executable: c:\php\php5isapi.dll

Win XP sp3 with IIS 5.1 and PHP 5.2.10.

I've unintalled and reinstalled a few times thinking I may have pooched something, but no love.

Brashquido's picture

Prompt to download PHP file

Have a look at this guide I wrote on troubleshooting when getting a prompt to donwload a PHP file.

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

Anonymous's picture

The specified module could not be found.

Hi Ryan, I am glad that you are still reply the question regarding this thread. I had done all as instructed. But while loading phpinfo.php, I got "The specified module could not be found." I am using WindowsXP SP2, IIS5.1, php-5.2.10, pecl-5.2.6 .

Anonymous's picture

Popup gone - thank you!

So, if this isn't the weirdest thing I've ever seen...

So, per your advice, I look at your pop-up tutorial as well and go through each step making certain that everything is as it should be. I open the php.ini and find all the possible settings and everything is fine.

I then retry my phpinfo.php file (hello world) and BAM! Everything is working just fine. The ONLY thing I did was let the computer sit overnight and opened and closed the INI file - I MADE NO CHANGES!!

So, the only thing I can think this type of error relates to is your very last step - RESTART the machine - although I did do exactly that when I performed the install.

Anyway, thank you for your guide and your help. NOW, I can learn me some php!

Anonymous's picture

MySQL

Not really a comment, but a problem. I've followed all your steps &when I run "phpinfo" MySQL doesn't appear. Can you point my in a direction that I can check to see what's missing? Thanks