How To: Install PHP5 on Windows Vista

A lot of people asked me how to install a web server on Windows Vista, well guess what installating PHP on IIS is now easier then ever! Here’s how to do it:

Download and Install PHP

  1. If you haven’t done it yet, download PHP from http://www.php.net/downloads.php; I used the zip package for this tutorial.
  2. Unzip the file in C:\PHP. You can unzip anywhere as long as there are no spaces in the path.
  3. Copy C:\PHP\php.ini-recommended and rename it to php.ini
  4. Go to Control Panel » System » Advanced Settings » Environment Variables. In the System Variables click Path and then Edit and enter “C:\PHP; “(or “;C:\PHP” if you put it at the end).
  5. Still in Control Panel » System » Advanced Settings » Environment Variables » System variable; Click New, in Variable Name enter “PHPRC” and in Variable Value enter “C:\PHP”

Note: Instead of doing Step 4 and 5 you could simple copy all non-php dll files to C:\Windows\System32 but It will be harder to uninstall / upgrade

Configure PHP

Now that PHP is installed, we need to make some modification to the configuration file (php.ini) to make sure it will work on Windows Vista.

  1. Create a Session State directory and edit php.ini to point to it. insert session.save_path = “C:\PHP\SessionFolderName” in php.ini
  2. Modify the PHP Extensions directory. search for extension_dir and set its value to “C:\PHP\ext”
  3. Enable extensions you plan on using. To do this simply uncomment (remove the semicolon “;”) the ones you want
    1. php_gd2.dll This will be useful if you plan on manipulating images.
    2. php_mysql.dll This one is required for MySQL functionality.

    There is a lot of extensions, enable whatever you need…

Configure IIS

By default, IIS is not installed on Windows Vista, but is available freely… If you don’t know how to install it just follow this link. While installing, make sure you select the ISAPI Extension component or the CGI component. You will need one of these to run PHP on the server. Let’s teach IIS how to handle PHP files.

  1. Go to Control Panel » Administrative Tools » Internet Information Services (IIS) Manager
  2. Click on “Handler Mappings”
  3. Click on the “Add Script Map”
  4. Fill the dialog box then click OK
    1. Request Path: *.php
    2. Executables: C:\PHP\php5isapi.dll
    3. Name: PHP
  5. On the “Add Script Map” dialog box, click yes
  6. Test it!
    1. Just create phpinfo.php with <?php phpinfo(); ?> in it in c:\inetpub\wwwroot

This entry was posted on Saturday, July 12th, 2008 at 12:16 pm and is filed under Developement, PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply