Windows: Installing PHP

While many admins choose Linux with Apache as their server software of choice there is an alternative. Windows and IIS. This tutorial will show you how to install PHP on a Windows server.


First lets download PHP from php.net. Select one of the zip versions preferably in the 5.x branch. Do not install PHP with the installer. Once you have PHP downloaded open a connection to your server using remote desktop. Make sure when you connect you select options. When you see all the options at the top click local resources. Check the box that says bring local disks to server. Now type in your admin login and password and connect. A box will popup asking if you want to bring your disks to the server. Click OK.Now you’re connected to your server. Open My Computer and you’ll see the server disks as well as your disks. Browse to the servers C:\Inetpub directory. If you have Inetpub on a different drive than C then browse to it. Now minimize the RDP connection. On your own computer browse to where you downloaded the php zip. You did download the zip didn’t you? Again don’t use the installer. Extract the zip. You should now have a folder called php-5.x.x.

Now we’ll move the php folder to your server. Right click the folder and select copy. Maximize you RDP connection. Make sure that C:\Inetpub is open. Right click and select paste. It might take some time for the menu to popup after you right click. It will. Select paste you’ll see a transfer box come up and it will transfer the php-5.x.x folder to C:\Inetpub. Another option and maybe a faster option is to start remote desktop and download PHP on the server.

Now that you have PHP downloaded and in place in C:\Inetpub it’s time to set IIS to use it to parse .php pages.

First thing to do is rename php.ini.recommended to php.ini. We won’t edit it at this time. The defaults of the recommended ini is good to get PHP running.

First thing to do is set up the path to php in Environment Variables.

  1. Click start and right click My Computer.
  2. Select the Advanced tab.
  3. Click Environment Variables

In the bottom box select Path and then Edit button. At the end of the Path variable add ;C:\Inetpub\php-5.x.x.
Substitute the folder path to what folder you actually have PHP in. There is one thing we need to do while you have the variables box open. Click the New button. In the Variable Name field put PHPRC. In the Variable Value field put C:\Inetpub\php-5.x.x. All done close that out and click apply for the changes to take affect.

Note: You might have to reboot the server so the new path and new variable take effect. To test it open a command window and type php. If you get an error then you’ll have to reboot. Don’t yet we still have work to do.

Now lets configure IIS to use PHP.

Open up IIS Manager. Start > Administrative Tools > Internet Information Services (IIS) Manger.

First thing we’ll do is add a new web service extension and enable it. In the left pane click on Web Service Extensions. in the left you’ll now see some options. Click add new web service extension. A box will popup. For the Extension name add PHP-IASPI. Click Add to add the required file. Browse to C:\Inetpub\php-5.x.x or whatever folder you put php in and select php php5isapi.dll. Check the Set extension status to allow box. Click ok to apply. IIS is now setup to use PHP, but, we aren’t quit done yet.

While still in IIS Manager expand My Websites. If you only have Default Website it’s a breeze getting PHP running.

Right click Default Website and select properties. Once the properties window comes up select Home Diretory tab. In Excutive settings in the dropdown select scripts only and click create. If you already have ASP or other scripts running on the server the Application will already be enabled for scripts. If you see an application name then skip the above step.

Click on the Configuration button. Click Add. When the box comes up you’ll see the Executable box with a browse button next to it. Click browse and navigate to the php5isapi.dll the same as you did when you added the web services extension. In the extension box add php. Uncheck Verify if exists. Click OK and apply. If you need to have php parse different extensions use the same procedure to add more extensions.

All done. Now it’s time to test it out. Open Note pad and put < ?php phpinfo(); ?> in it. Save it as test.php in your websites root. Make sure it doesn’t save as test.php.txt. If it did rename it to test.php. Open up your browser and browse to http://yoursite.tld/test.php. If you see the PHP information page then you have done everything correctly.

If you got an error when you tried to run php at the command prompt then reboot your server.

If you don’t see that page then retrace your steps to find your error.
If you have more than one website and if you want PHP to work in each you have to configure each site like you did the Default Website. In the next installment we’ll add some extensions and set up PEAR.

Leave a Reply

8 Comments on "Windows: Installing PHP"

Notify of
avatar
wpDiscuz