In the first part of this post I covered installing and configuring PHP and IIS. This post can be read here Installing WordPress on Windows using SQL Server 2008 R2 Part 1. In the second half of this blog post I will cover the Configuration of you SQL Server and setting up your database ready for WordPress. I will also cover the installation steps required to get WordPress up and running and sort out some minor issues that may arise.
Configure the SQL Server Database
This post assumes you all ready have a SQL Server Instance running.
Firstly we need to create our WordPress Database. To do this open your SSMS (SQL Server Management Studio) and right click on your Databases folder. Select New Database from the menu to begin.
Give your database a name and leave all other options as default. Next we need to create our user to access our database from WordPress. To do this expand your Security folder in your SSMS and right click on New Login option.
Give your login a Name and set the password for the user. You can also choose whether or not to enforce password policy. Make your selections and click the User Mapping option from the left hand navigation.
Next grant your user access to the new database you created earlier. You will need to set the Default Schema to dbo if you do not have a custom one already setup for this. Also set the permissions of the user on this database. An example is shown above of the roles to assign.
Install and Setup WordPress
Firstly we need to download the correct version to run on IIS. To do this got the the following link http://wordpress.org/wordpress-3.4-IIS.zip and save the ZIP file to your machine. Then you will need to extract the WordPress folder to your machine. Once you have done thos you need to copy the WordPress files from the WordPress folder to your Blog directory that your setup earlier for your website. My path was C:inetpubwwwrootWordpressParentwordpress. Please note do not extract the whole folder only the content of it.
Once you have extracted the WordPress site set the permissions for the IUSR user on the WordPress root folder to be full control. once you have done this create a web.config file in your WordPress root directory and paste in the following config text.
[gist id=5037757 file=WordpressWebConfig]
The final thing we need to do now is install the wp-db-abstraction plugin on our WordPress instance. To do this go to the following site
and download the latest version of the plugin and save it to your machine. Extract the plugin to your machine and do the following:
1.) Upload the wp-db-abstraction.php and the wp-db-abstraction folder to wp-content/mu-plugins folder. This should be parallel to your regular plugins directory. If the mu-plugins directory does not exist, you must create it.
2.) Move the db.php file from inside the wp-db-abstraction folder to wp-content/db.php
3.) Now we need to run the install wizard of WordPress and finish our Install. To do this browse to the $your_wordpress_url/wp-content/mu-plugins/wp-db-abstraction/setup-config.php page through IIS.
This will then prompt you with a configuration setup window for WordPress.
Click the "Lets Go" button to move to the configuration page. This looks like a standard WordPress config page but this one has a DB Type field. Select the correct driver (shown above) and enter in all the required information for the database and the user we created earlier. Then click submit. If all goes well and you have followed the steps from above you will be presented with the following prompt:
Click the install button and setup your WordPress details. At this point WordPress will be up and running and most blog posts end here and say "now your done". Well actually that's not true. What you will find is that all looks OK until you try and look at your Posts or Media lists.
You will notice that the counts says (1) but the number of posts showing is zero. This is because the current version of the WordPress DB Abstraction plugin ships with a bug. This bug is with a RegEx in the translations.php file. It adds a trailing ";" to some of the queries which causes SQL to fall over. To fix this browse to this file from your WordPress root folder. My path was as follows: C:inetpubwwwrootWordpressParentwordpresswp-contentmu-pluginswp-db-abstractiontranslationssqlsrv. Open up the translations.php in a text editor and go to line 726 in the file. Here you will find the RegEx line that needs to be changed. Change the code from:
[gist id=5055404 file=WpAbstractBugFix]
Once you have done this save your changes and then refresh your posts page. You will now see all of your posts display correctly. The ultimate test to make sure your WordPress is working is to do an upgrade. You should be able to go to the Dashboard and upgrade your version of WordPress. This should work just fine and now you are all set.
And there you have it a WordPress Blog integrated as a sub folder of a main website. If you browse to your home page and click on the Blog link you should have setup earlier you will get your blog home page as planned.
Below are some helpful links that I used as resources to create this install guide.