Select Page

Installing PHP in Windows requires more than just running the PHP installation package. There are additional actions that need to be taken before you can host PHP web pages. Unfortunately, the installer doesn’t do this and you have to set it up manually yourself. You won’t find any documentation on the PHP site, but the procedure is fairly easy to follow.

The first thing you need to do is get the latest version of PHP for Windows from http://www.php.net/downloads.php. Run the installer and follow the steps until you reach the Web Server Setup form.

Select IIS CGI if you are installing PHP on IIS 5 or earlier (i.e. Windows XP). If you are using IIS 6 or 7 (Windows 2003 or 2008), use the IIS FastCGI option if its installed because it will give PHP better performance on your server.

Web Server Setup

Click on the drive icon next to PHP and select Entire feature will be installed on local hard drive. This will install all of the libraries and documentation that come with PHP. Its easier installing everything now than finding out later that you need a certain feature. I’ve also found that install PHP on C:\PHP\ works better than installing on C:\Program Files\PHP\. I’m not sure why, but there is probably a setting I’m missing when I install it in the Program Files folder.

 Choose Items to Install

You’ll get this error message at the final step of the installation:

Error trying access httpd.conf file. You will need to manually configure the web server.

Press OK and then press the Finish button when the next form is displayed.

Now you need to test the PHP installation by creating a virtual folder in IIS with a PHP page in it. Name the virtual folder as test and the web page as index.php.

Place the following code in index.php:

<?php

  echo ‘Test’;

?>

When you browse to this folder, i.e. http://localhost/test/, you will get the following error message:

Directory Listing Denied

In order for PHP to work properly, you need to modify the php.ini file, create a subfolder, and make some changes to IIS. This procedure is described in the following steps:

  1. Create a folder call Temp in the folder where PHP was installed.
  2. Open the php.ini file in an editor. This settings file is located in folder where PHP was installed.
  3. Search for upload_tmp_dir and session.save_path in php.ini. Change the locations to point to your Temp folder: C:\PHP\Temp.
  4. Go into the IIS management console and right click on Default Web Site or the web site that you created to install your PHP web site in. Select Properties and open the Home Directory tab. Press the Configuration button to open the Application Configuration form.
  5. Press the Add button and enter the following information (see image below):

    Executable: C:\PHP\php5isapi.dll
    Extension: .php
    Limit to: GET,HEAD,POST

    Add/Edit Application Extension Mapping
    Press the OK button to accept these settings. Press the OK button again to return to the Properties form.

  6. Select the Documents tab and press the Add button. Set the Default Document Name to index.php. This is the default document that gets opened when you browse to a folder (i.e. http://localhost/test/).

Test the PHP web site by browsing to it (i.e. http://localhost/test/). You should see the word Test displayed in web browser.

Print Friendly, PDF & Email
Translate »