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

Warning!: Your PHP installation don't have the MySQL extension -

Hi,

I am trying to install TestLink 1.8.5 on windows XP with MySQL 5.1/PHP 5.2.4/IIS 5.1.

While installing I got warning :
"Warning!: Your PHP installation don't have the MySQL extension - without it is IMPOSSIBLE to use Testlink.Failed! "

How i should proceed to come out of this. Please tell me the procedure about what changes i shoul have to make in php.ini file or please tell me the other way.

Thanks,
Pradeep

Brashquido's picture

Enable MySQL extension

Hi Pradeep,

open your php.ini file and find this;

;extension=php_mysql.dll

Simply delete the semi-colan (;) at the start, save php.ini and then restart IIS. Assuming the rest of you PHP environment is setup correctly you should now be able to connect to you MySQL server.

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

Anonymous's picture

PHP 5 Install

Well, following the instructions went well until the part of php5isapi.dll - the binary zip file from PHP does not have that file in it.... trying php5ts.dll or php.exe similar to PHP4 install does not work either.
And - the IIS5 server simply refuses to start - period.
The solution appears to be this - download the php5isapi.dll file add it to the PHP5 directory, move php.ini to the windows folder and do not use the PHPRS entry,instead just set the path as normal ... then IIS5 will start and PHP5 works fine.

To fix IIS not restarting if there is a problem, use services to set it all to manual and then use the IIS admin tool with the server stopped to change or remove entries - then reboot the machine.Then restart the server again using services and set it to automatic if desired.

A note also - if you use the PHP5 msi installer - it will try install to C:\program files\Php and due to the space in the directory may have problems - instead install to c:\PHP much simpler and it works better.

Brashquido's picture

No ISAPI in PHP 5.3 onwards

The ISAPI dll was dropped from the PHP distribution with the release of version 5.3, so yes from now on it will be a separate download or compile it yourself from the source. Ideally you should not move the php.ini file to your windows directory, as this can cause issues with upgrading and generally speaking it is not a good idea to mix application configuration files with your operating system. The PHPRC variable is one of the first things PHP looks at when loading the environment to obtain the location of your php.ini file, and this is what you should use to set the path to your global php.ini file.

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

Anonymous's picture

Thanx a lot

I'm very Happy bcoze of this step by step guide I found I really thankful to this site which guide me how to configure PHP on IIS now My pc has running PHP as well as ASP

Thanx a lot

--Jignesh Parmar
email:

Anonymous's picture

Beautiful Instructions

It seems everytime I read instructions on installing PHP on IIS, they are different and usually don't work.

These instructions were not only concise, clear and easy to follow, but they worked perfectly the first time!

Thanks Heaps.

Anonymous's picture

wonderful guide

wonderful guide thanks a lot
but i have a problem. when i click the configuration button it doesn't respond. so i have been stopped there.i have not been able to go further.

Brashquido's picture

Doesn't respond? Is the

Doesn't respond? Is the button greyed out? If so have a look at this guide dealing with Working with IIS 6 scriptmap inheritance. Guide is for IIS 6, but same applies for previous versions of IIS. Apart from that make sure the window isn't hiding by using your alt-tab key, and also check out the Windows event log for any IIS related issues. Have you tried adding the application mapping via the command line as described in the guide?

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

Anonymous's picture

Redirecting to "Apache2-Default".

I followed the instructions, but when I hit my default website: http://localhost/

I am redirected to http://localhost/apache2-default/.

When I hit http://localhost/index.php, which is where I have the call to phpinfo(), the browser downloads the file instead of serving it.

Interestingly, if I hit a URL that is mapped through my hosts file I don't get the download: just a broken link.

I've double checked my application mappings, and I made sure IUSR has permissions to the PHP install directory. Could ISAPI filters be the problem?

I'm out of ideas. Can you help?

Brashquido's picture

Is Apache installed?

Do you have Apache installed along side IIS? Doesn't sound like you are actually hitting the IIS server at all. Check your services and make sure IIS is actually running, and if it isn't then start it. If it doesn't start, then I'd say you'll need to stop Apache first.

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