Setting up WordPress on Windows XP to use IIS 5.1

I recently built a Windows XP virtual machine with the intention of doing wordpress theme development and testing on it.

Getting WordPress up and running normally requires running Apache, MySQL and the wordpress binaries, but instead of running Apache, I wanted to use the version of IIS included in Windows XP.

Getting everything for WordPress up and running wasn’t that difficult, but I wanted to record my steps and sources in case anyone else is considering doing the same.

Also consider installing FTP with IIS so that you have a mechanism to move files in/out of the VM.  I choose to go this route so I can more easily replicate my production server configuration since mapping drives and Windows networking is out of the question in an internet-facing/production scenario.

PHP Installation

After IIS is installed, and you are all patched up-to-date on XP, then perform the following to install and configure PHP on IIS 5.1:

  1. Download PHP 5.2.10 (the zip file for a manual install) from the PHP download center – http://us.php.net/get/php-5.2.10-Win32.zip/from/a/mirror
  2. One the file is downloaded, create a ‘PHP’ directory on your hard drive (i.e., C:\PHP) and extract the contents of the zip file to that directory.
  3. Add the directory to the PATH environment variable.
  4. Rename the ‘php.ini-recommended’ file to ‘php.ini’.
  5. Open the php.ini file, then uncomment and modify settings as follows:
    1. Set cgi.fix_pathinfo=1.
    2. Set cgi.force_redirect = 0.
    3. Set open_basedir to point to a folder or network path where the content of the web site(s) is located.
    4. Set extension_dir to point to a location where PHP extensions reside. Typically, for PHP 5.2.X that would be set as extension_dir = “./ext”
    5. Enable the required PHP extension by un-commenting corresponding lines, for example:
      1. extension=php_mysql.dll
    6. Set the time zone variable (date.timezone)
    7. Save the file.  To test if the PHP installation is successful, run the following from the command line prompt:C:\PHP>php –info

      If all is well, the console will scroll full of text that shows the current PHP configuration.

      Before proceeding any further, copy the PHP.INI file to the \windows\system32 directory.  This matters and will cause IIS

Now that the PHP core is installed and working correctly, it is time to move on and configure IIS to correctly handle PHP file mappings and to help it understand how it is to render PHP script code.

Normally under Windows 2008 and IIS 7, FastCGI would be used to assist in rendering the PHP code, but such doesn’t exist with the older version of IIS (5.1) that runs on Windows XP.  We’ll have to rely upon an ISAPI extension instead.  That’s why we grabbed 5.2.10 as it has the pre-compiled ‘php5isapi.dll’ file that we’ll need in the following steps.  The later (5.3 at this writing) distributions of PHP don’t include this file, but it is possible to compile it yourself if you want to do so.

  1. Open the IIS Manager
  2. Open the properties of the default website and go to the Home Directory tab.  Ensure the execute permissions are set to Scripts Only and then click the Application Configuration button.
  3. Add an application mapping for php files as shown below:image
  4. Save the configuration and then open a command prompt and run iisreset.
  5. After IIS has been restarted, open your web content directory (c:\inetpub\wwwroot) and create a phpinfo.php file and put the following code in it:<?php
    phpinfo();
    ?>
  6. Save the file, and then open a browser and navigate to the phpinfo.php file.  If all is configured correctly, a screen similar to the following will be rendered in the browser…image
  7. Note that if this is an upgrade/reinstallation of the PHP version (or downgrading) make sure to replace the ‘lib*.dll’ files in the \windows\system32 directory with the files that come from the php version being installed…  Failure to do this will prevent some of the extensions (namely mySQL) from loading.I had to learn this the hard way and it caused me to pound some sand for a bit until I figured out what had happened.
  8. Look through the output of step 6, above, and verify that the ‘mysql’ extension loaded.  If it isn’t listed in the webpage, then something is awry and needs to be corrected before phpMyAdmin can be installed.

Congratulations! PHP is now installed and functioning correctly on IIS 5.1.  Now we’ll move on to the MYSQL installation and configuration.

MySQL Installation

First off, download the mySQL binaries from the following location – http://dev.mysql.com/downloads/mysql/5.1.html#win32

I chose the .msi installer for ease of installation and uninstall/reinstallation if it became necessary at a later point in time.

I performed a detailed configuration setup and chose all defaults and let the installer do its job.  Once finished, I ran the instance configuration and chose a ‘developer’ workstation configuration and secured the install and finished up.

phpMyAdmin Installation

Now that mySQL is installed, it’s time to install phpMyAdmin so that we can have a good GUI-based admin client for mySQL.  Although this isn’t expressly necessary for a development environment, I run it on my production server and feel that I need to mirror things as much as possible.

Installing phpMyAdmin is a bit of a chore – there is no easy way to say it.  Fortunately the “how-to” article at IISAid.com takes as much of the leg work out of it as possible.  The install really goes quickly the 2nd or 3rd time around… it just seems long the first time…… http://www.iis-aid.com/articles/how_to_guides/install_and_configure_phpmyadmin_iis

Once finished with the installation/configuration, be sure to create a wordpress database and user account.  Also grant all access permissions to this user account on the wordpress database.

Once finished, you are ready for the final step…

WordPress Installation

Well, there’s not much to say about this that hasn’t already been said…:D  It’s really nothing more than downloading the bits from www.wordpress.org and following the “5-minute install” walkthrough.

Final Thoughts

So after all of this is finished up, you should have a nice, smooth (and local) installation of WordPress up and running.  I love the VM aspect of it as it makes it portable and easily duplicated if needed, and makes it very nice to easily test things against – especially if you are offline.

Please let me know if you have any comments or questions!

Leave a Reply

Your email address will not be published.

%d bloggers like this: