How to setup Wordpress on Windows Server 2008 with IIS 7

I recently had to install and setup a few Wordpress blogs onto Windows Server 2008. No biggy I thought. I'll just install Wordpress using the Web Platform Installer and away I go. Unfortunately it's never that easy! Below are the steps I took, the pitfalls I came up against and the solutions I have to getting Wordpress setup.

First up, setup your domain in IIS 7. For the purpose of this article I will assume that you have done this and are looking to setup Wordpress to this domain.

If you don't already have the Web Platform Installer setup on your server go over to http://www.microsoft.com/web/downloads/platform and download the installer.

Step 1: Install Wordpress

Once the installer has downloaded, run it from the server and when it starts go to 'Applications' on the top menu bar and select 'Wordpress' and click 'Add' and then 'Install'.

Step 2: Enter an admin account for MySQL

You will be asked to setup a root username and password for MySQL as part of the installation. Remember to write these details down somewhere as you will be using them later during the installation. The installer will now download Wordpress and setup PHP and MySQL for you.

Step 3: Enter the Wordpress location

Once the files are downloaded you will be asked to select where you want Wordpress installed. If you setup a domain already in IIS then simply select the domain from the drop down list. By default Wordpress will want to install in yourdomain.com/Wordpress - just remove the word Wordpress from the application textbox if you'd like your install to be on the root level or set it to another name if you'd like to be inside a folder eg to get yourdomain.com/blog just enter blog into the Wordpress application textbox.

Step 4: Lastly enter the database info for this install of Wordpress

Click on Continue and you will be asked to enter the database details. On this screen leave the dropdown on 'Create a new database' and enter in your root database user and password which you created at the start of this install. Now enter in your database username, password and database name you want for your project. The location of the database is usually 'localhost'.

NOTE: Make sure your password does not contain any special characters. If you enter a password with characters like !"£$%^&*() then you will have an issue where the website will not load for you when you go to view it later on. I think this is a bug as part of the web platform installer. I also had an issue if my username contained dots or dashes.

Once you're happy with the details click Done and Wordpress will be installed for you. You can click on the link to launch your website on localhost on the server to ensure everything is working as expected.

Potential Pit Fall: Wordpress installed ok but returns a blank / empty website

This happened to me if I use special characters in the database username/password/database name fields during the install. Delete the new Wordpress folder you created and start the above process again using simple text/number combinations to confirm this is your error.

Before your Wordpress site is ready for production you need to configure some settings in the wp-config.php file for Wordpress. This file is located in your website wordpress folder you setup during the installation.

Go to https://api.wordpress.org/secret-key/1.1/salt/ and copy the entire text that you receive. Go back to your wp-config.php file overwrite the empty values with these new values containing the keys. Now click save to close down the file.

Allow SEO friendly URL rewrite rules:

Create a new web.config file (if one does not already exist) and set it up with the following rewrite rules:

 

Aaaannnddd you're done!

Wordpress should now be working as expected for you! Read on if you'd like to customize the install to allow larger file uploads, add another installation or Wordpress or even add a mutlisite wordpress install.

Increase the file upload size for PHPMyAdmin/PHP

By default PHP gives you a pretty small 2mb limit for uploads. The good news is that this is a super easy thing to change. If you installed PHP in the default location then it should be located in C:\Program Files\PHP. Scroll down to php.ini and open it in notepad. Find the following and update them as you see fit:

post_max_size =8M 
upload_max_filesize =2M 
max_execution_time =30 
max_input_time =60 
memory_limit =8M 

Change to (can be whatever size you require here I've the settings set to 20MB):

post_max_size = 20M 
upload_max_filesize = 20M 
max_execution_time =500 
max_input_time =500 
memory_limit =128M 

How to add another Wordpress installation

You can add another Wordpress install by using the Web Platform Installer and selecting Wordpress again. The installer will know that you already have PHP and MySQL setup so it will just ask you where you want Wordpress installed. Simply follow the normal steps (put it on a domain, give it a folder and enter database settings) and your all set.

How to setup Wordpress to be a Multi-website installation

By default Wordpress is setup for 1 website but you can easily set it up to handle multiple website if you want - instead of installing Wordpress into loads of sub folders. All you have to do is open your Wordpress wp-config.php file and before the line enter the following:

define('WP_ALLOW_MULTISITE', true);

Now log into your Wordpress site and go to Tools -> Network and select Subdomain or SubFolders and follow the rest of the onscreen instructions.

How to turn on detailed PHP error messages:

If you or your developer wants to temporarily turn on error messages on your server then go to your PHP.ini file (C:\Program Files\PHP) and locate the following line from display_errors = Off to display_errors = On. Open IIS and restart the website. You will now have detailed PHP errors.

You can also turn on detailed error reports through IIS by selecting the domain and double clicking on Error Pages. On the right hand side you can click on Edit Feature Settings and choose Detailed Errors to activate 404 errors. To turn on detailed errors for server 500 errors simply right click on Status Code 500 from the list of codes in Error Pages in IIS and select Edit Feature Settings and click on Detailed Errors.

Be sure to turn off these detailed errors before going live with your site if you want to avoid displaying sensitive information about your server and application to potential hackers!

Summary

As you can see there isn't much to setting up and installing PHP, MySQL and Wordpress onto a Windows Server 2008 box. Hopefully you'll find this guide useful.

blog comments powered by Disqus

Get In Touch

Follow me online at TwitterFacebook or Flickr.

Latest Tweets