jump to navigation

IIS7, PHP and WordPress on Vista May 12, 2008

Posted by Peter Hornby in tech.

I spent a substantial part of the weekend getting WordPress running on my laptop. There was actually a good reason for this, other than my strange attraction to hitting myself over the head with a brick. Actually, I’m planning to set up a blog for the Saddleback Master Chorale in the next couple of weeks, and I thought that it would be useful to develop some experience with the non-hosted version of WordPress. What made the effort somewhat more challenging was that my laptop runs Vista, so I decided to use IIS7 to host the WordPress installation.

Many people have blogged aspects of this challenge, and I wouldn’t pretend that this is the canonical story. But there were some pieces of the puzzle which caused me more trouble than I expected, so I’ll try to concentrate on those.

Installing IIS7

IIS is not installed by default on Vista, so you have to go to the “Turn Windows Features on and off” selection in the “Programs and Features” control panel. The key thing to remember is to make sure that you’ve enabled the CGI feature while you’re checking IIS options.

Finding and installing FastCGI

Many people recommend using Microsoft’s FastCGI if the application framework you’re using supports it,as PHP does. Reusing Windows processes is a big performance win, and there are reliability benefits too, especially since FastCGI is thread-safe. So how do you get FastCGI? If you’re running Windows Server 2008, you’re in good shape, since FastCGI is bundled, but Vista is another story. Microsoft released a technical preview version of FastCGI last year, but that’s now gone, and it’s now only available as part of Vista SP1. And that was my first problem – how to get hold of Vista SP1.

Finding Vista SP1

Windows Update, you’d think. Not so fast, sparky. Microsoft says that they’re rolling out Vista SP1 gradually through Automatic Updates, but if you want to jump the line, you can manually scan for updates. I did that. No sign of SP1. Luckily, there’s a KB article which addresses the problem, offering seven possible reasons why SP1 is not offered by Windows Update even after a manual scan. Actually, it’s really six, since Cause 1 is “You’re already running SP1”. The two possibilities which seemed pertinent were Cause 5 – “SP1 won’t be offered if Windows detects that you have device drivers which might cause problems with SP1” – and Cause 7 – “SP1 won’t be offered if other Windows updates are offered – it needs to be installed as a single update operation”.

So I spent a couple of hours addressing these points, with no success. More scrabbling around in Google turned up another KB article which, while describing the ways SP1 can be obtained, referred to the need to update the Kernel Streaming driver (ks.sys) before updating to SP1, since the older driver version can cause a crash during the update process. This driver comes into play, I think, with the Logitech webcam on my Dell XPS M1530 laptop. The ks.sys update was made available in early April as a Microsoft download. I updated this driver, and suddenly SP1 appeared in the Windows Update list.

So let’s move on to the real work.

Downloading and installing MySQL

I Installed MySQL 5.0, and used the command-line configuration tool to create a user and a database, as described in the WordPress installation instructions. That at least was simple enough.

Downloading and installing PHP

I downloaded PHP 5.2.6, and installed it in C:\inetpub, as recommended by Scott Hanselman in his essential screencast on getting PHP working with IIS7 and FastCGI. The next step is to use IIS Manager to create a handler mapping to have IIS route .php files to the FastCGI module. This stuff is all covered by Scott Hanselman and also by Ryan Dunn’s screencast on Channel 9. Note that if you’re out for performance, there’s significant benefit to be had from using the non-threadsafe version of PHP, since FastCGI ensures that requests are single-threaded through service processes. The PHP core is threadsafe, as are most PHP extensions, but there are third-party extensions which aren’t, and there can be instabilities if you use a non-threadsafe PHP with the ISAPI interface. See the relevant entry in Mike Volodarsky’s blog for more.

Configuring PHP

There are a number of steps you need to take here, and you’ll be editing the php.ini file. The main work is to wire PHP up to MySQL. You need to tell PHP where its extensions directory is (the extension_dir option) and you need to make sure that the reference to the MySQL extension (extension=php_mysql.dll) is uncommented. One final thing, which caused me substantial headscratching, is to tell PHP where to look for this php.ini file. You’ll need to create a registry key (HKLM/Software/PHP/IniFilePath) to hold this location, and then restart IIS to have PHP read it. The PHP documentation for this is here. Check that PHP is loading the correct .ini file (and that PHP is wired up properly) by browsing to http://localhost/phpinfo.php.

Installing WordPress

I installed WordPress 2.5.1 into C:\inetpub\wwwroot\blog. The wiring between WordPress and the MySQL database you created earlier is done in wp_config.php. Here’s how the relevant piece of the file should look.

// ** MySQL settings ** //
define('DB_NAME', 'putyourdbnamehere');    
define('DB_USER', 'usernamehere');     
define('DB_PASSWORD', 'yourpasswordhere'); 
define('DB_HOST', 'localhost');

And, then, browse to http://localhost/blog/wp-admin/install.php, and after a couple of install forms, you should have a running blog.

I wish you luck!



1. Bradford - December 18, 2008

Thanks for the walkthrough. I’m getting some strange behavior on my blog. I can access the main page (index.php) and the admin pages, however any other pages or post pages just give me an “Address Not Found” error in firefox, NOT an IIS error. I’ve tried it with or without pretty permalinks.

2. hybridwolf - April 21, 2009

Thanks so much for the process, sounds simple, I’m betting its not :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: