Friday, September 05, 2008

There are various tutorials (including in the PHP distributable) on how to install PHP on Windows XP for development.  Few are this straightforward, and none (that I could easily find) use the ZIP file, allowing for you to easily upgrade and/or remove PHP cleanly from your system. 

  1. Download PHP from PHP.net.  Get PHP in the ZIP distribution.
  2. Create the directory c:\php, and expand the distro in that new directory.
  3. Add the new directory to your PATH variables.  PATH variables are found by right-clicking on My Computer -> Properties -> Advanced -> Environment.  You'll see many system variables.  Select "path" and edit, adding "c:\php" (without the quotes) preceding or following it with a semicolon, depending on where you put it in the string.
  4. Copy and rename php.ini-recommended to c:\windows\php.ini
  5. Edit php.ini setting the following:
    1. doc_root = c:\inetpub\wwwroot
    2. cgi.force_redirect = 0
    3. extension_dir = c:\php\ext
    4. (optional) uncomment extension = php_mysql.dll
  6. Add ISAPI to IIS by first opening the IIS MMS.  Right-click on Web Server -> Properties -> Home Directory -> Configuration -> Mappings
    1. Add c:\php\php5isapi.dll, setting .php as the extension, then click OK twice to Home Directory
    2. Add same DLL to the ISAPI modules, naming the module "PHP"
  7. Change to Documents tab, and add index.php (to allow for full PHP sites)

Make sure all of your settings are set by stopping and restarting IIS by running NET STOP iisadmin, then NET START w3svc.

To test, create a new IIS virtual directory and create a file index.php, edit it adding the following code:

<html>
<head></head>
<body>
<?php phpinfo(); ?>
</body>
</html>

Save the file, then open your new IIS app.  If all goes well, you'll be looking at a PHP screen enumerating all of your file settings.

If you want to remove PHP, just reverse the steps starting at #7 and go backwards.  It's really that easy.

[Update: 10/7/08]

In a new virtual XP Pro install, I have had 401.3 errors on this install.  I found this (rather draconian) "fix" to the 401.3 error I was receiving.  YMMV, but it did seem that the install was having some strange ACL issues.

Technorati Tags: ,,,