• Installing WordPress 2.9.x on an IIS 6.0 web server (Windows Server 2003) and enabling custom permalinks

    by  • January 18, 2010 • iis, windows, Wordpress • 2 Comments

    A few clients I’ve worked with in the past are Microsoft-centric having Server 2003 based dedicated servers but want to be able to host WordPress blogs. Luckily it’s relatively straightforward to get a WordPress blog up and running  on IIS by the following steps.

    This is written for Server 2003 (running IIS 6.0) and I’m using a virgin Server 2003 SP2 install. First we’ll configure IIS so it can run PHP scripts, and then configure WordPress appropriately. 7QS2A4HU29PC

    Note: that these are basic steps to get WordPress running on a development machine and not for staging/launch, thus you should check out detailed security notes on WordPress/mySQL and IIS to harden up security before exposing the blog to the public interwebs.

    1. Enable running of PHP scripts

    1. Ensure one of your server roles is as an Application Server which will provide access to IIS (otherwise FastCGI will complain…)
    2. Install FastCGI from http://www.iis.net/expand/fastcgi (I’m using the latest release version and not the 1.5 RC)
    3. Then, install PHP for Windows, which you can get at  http://windows.php.net/download (currently version 5.3.1). I selected the ‘non-thread safe version’, as recommended by http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60 (section entitled ‘Download and Install PHP’)
    4. Part of the PHP installation process will ask you what web server you are using. Select ‘IIS FastCGI’ and it will associate the FastCGI ISAPI filter with IIS , meaning you can skip the section ‘Configuring FastCGI Extension to Work with PHP’ on the iis link above. Feel free customise the install path or default PHP extensions to be installed.iis-php-fastcgi
    5. That’s PHP installed: To test it has been successful, create a folder and add a file index.php to it (I put this under C:\phpwebs\phpinfo), and copy the following code into it:
      1. <?php phpinfo(); ?>
    6. Now go into the IIS Manager in administrative tools, and under Websites/Default Web Site, create a new virtual directory. Give it a name (e.g. phpinfo) and select the folder you created, ticking Read and Execute permissions.
    7. Open up a browser and navigate to http://localhost/phpinfo. You should see the classic PHPInfo screen with the Server API down as CGI/FastCGI.phpinfo-fastcgi

    You may also want to check out the section entitled ‘Setting FastCGI Configuration for Optimal Functionality, Security and Performance with PHP’ at http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60.

    2. Installing and configuring WordPress 2.9.x

    1. Now IIS can run PHP scripts you can now grab the latest version of WordPress from http://wordpress.org/download/ and unzip the contents of the folder to your root for PHP web applications (i’ll keep using C:\phpwebs). In my case I’ll be using C:\phpwebs\wordpress. Make sure you persist the WordPress folder structure whilst unzipping.
    2. I won’t recommend a database technology but in this case I’ll be using mysql which you can get at http://dev.mysql.com/downloads/mysql/ (currently MySQL Community Server 5.1.42). I went for a typical install, and a ‘standard configuration’ in the MySQL Instance Configuration Wizard. I left the default options checked, and created a new, strong root password. When its ready, click Execute to update the MySQL configuration and start the mySQL service.
    3. I then created a new database entitled wordpress, a user entitled wordpress and granted the wordpress user ownership permissions on the wordpress table. (You can do this via the mysql command line tool, or via my favorite db admin tool, phpmyadmin). e.g. (note for production you should use something a little more secure)
      1. CREATE DATABASE wordpress; CREATE USER ‘wordpress’@‘localhost’ IDENTIFIED BY ‘pass123’; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON wordpress.* TO ‘wordpress’@‘localhost’;
    4. Now we need to rename wp-config-sample.php to wp-config.php and edit the file, specifically the following fields
      1. /** The name of the database for WordPress */
      2. define(‘DB_NAME’, ‘wordpress’);
      4. /** MySQL database username */
      5. define(‘DB_USER’, ‘wordpress’);
      7. /** MySQL database password */
      8. define(‘DB_PASSWORD’, ‘pass123’);
    5. Now in the same way we added phpinfo as a virtual directory within the IIS MMC snapin (step 1.6), we’ll add C:\phpwebs\wordpress as a virtual directory and allow ‘Read’ and ‘Execute’ permissions.
    6. If the database and wp-config.php have been set up correctly, navigating to http://localhost/wordpress should present a WordPress page asking you for a blog title and admin email address. When you click next you should be presented with a ‘Success!’ web page like the following:wordpress-installedMake sure you take note of the strong password that is created!
    7. Log in, enter ‘admin’ and the strong password you were presented with and you should reach the dashboard where you can change the password to something more memorable…

    And that’s it, bar one thing…

    One last thing… pretty permalinks

    WordPress uses .htaccess rules (from the Apache web server world) in order to achieve its pretty permalinks. Under IIS, you can enable pretty permalinks (WordPress dashboard->Settings->Permalinks) as long as the permalink has index.php as part of the permalink scheme. If you don’t keep the index.php, you will run into 404 errors whenever you try to navigate to a post or page. I wanted to get around needing index.php (for an extra dash of search engine friendliness) and there are many many articles on http://codex.wordpress.org/Using_Permalinks#Permalinks_without_mod_rewrite showing you how you can acheive this, including Microsoft’s own URL rewriter, which unfortunately only works with IIS 7+ (Vista/Server 2008 and up).

    I had the most success with the following:

    1. Download wp_url_rewriting ISAPI filter from http://www.deanlee.cn/wordpress/url-rewriting-for-wordpress-under-iis/ (currently at version 2.1)
    2. Register wp-url-rewriting.dll as an ISAPI filter within the IIS Management snapin. Right click on ‘Default Web Site’ and select the ISAPI filters tab, click ‘Add’, type in a filter name (I like WP Rewriter) and browse for the wp-url-rewrite.dll.
    3. Click ‘Apply’ and then restart IIS.
    4. Check the status of the ISAPI filter, if it hasn’t been loaded you may need to install the VC++ 2005 Redistributable from http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=32BC1BEE-A3F9-4C13-9C99-220B62A191EE, then try restarting IIS once more. This was the case with my virgin Server 2003 SP2 install.
    5. You should now be able to navigate to your wordpress admin dashboard and remove the index.php from your custom permalink structure: all pages/posts should now be accessible but without the requirement of index.php.
    6. The only slight issue I’ve noticed is a double hit when you go to /wp-admin with the ISAPI filter enabled.

    So there you have it, WordPress on IIS, with any custom permalink structure you fancy.


    .NET developer at thetrainline.com, previously web developer at MRM Meteorite. Awarded a PhD in misbehaviour detection in wireless ad-hoc networks.A keen C# ASP.net developer bridging the gap with APIs and JavaScript frameworks, one web app at a time.


    2 Responses to Installing WordPress 2.9.x on an IIS 6.0 web server (Windows Server 2003) and enabling custom permalinks

    1. Simon
      January 18, 2010 at 2:41 pm

      Great! This has been very useful for starting our WP-based intranet.

    2. Jason
      August 18, 2011 at 10:49 pm

      Thanks for this guide. It looks to be one of the best methods. We want to add a WP 3.x blog to one of our public websites but you mentioned guides for IIS/mysqp security – do you know of any off hand?

    Leave a Reply

    Your email address will not be published. Required fields are marked *