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.
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:
- 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
- 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.
- Add the directory to the PATH environment variable.
- Rename the ‘php.ini-recommended’ file to ‘php.ini’.
- Open the php.ini file, then uncomment and modify settings as follows:
- Set cgi.fix_pathinfo=1.
- Set cgi.force_redirect = 0.
- Set open_basedir to point to a folder or network path where the content of the web site(s) is located.
- 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”
- Enable the required PHP extension by un-commenting corresponding lines, for example:
- Set the time zone variable (date.timezone)
- 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.
- Open the IIS Manager
- 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.
- Add an application mapping for php files as shown below:
- Save the configuration and then open a command prompt and run iisreset.
- 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
- 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…
- 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.
- 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.
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.
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…
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.
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!