Installing WordPress on Windows using SQL Server 2008 R2 Part 1

Installing WordPress is a relatively simple task but I was recently asked to install a WordPress Blog with some unique requirements. The main requirement was that the Blog needed to be integrated into the main website structure and be accessed by a URL such as "".

After doing some reading this seemed perfectly OK except for the fact they wanted WordPress installing on it's native environment of Linux using MySQL. This instantly caused complexities so it was put forward that we run it on a Windows platform and use their existing SQL 2008 R2 database server to host the content.

This gave us some added benefits in that we did not need to worry about another backup and D.R solution for the new hardware hosting WordPress. After investigating installing WordPress using SQL Server it seemed perfectly simple but after looking around it seemed that lots of information was missing or scattered all over the place and things were not as simple as it first looked.

In light of this I was inspired to write this Blog post to share this information from one source rather than the headache of trying to hunt it all down. This post has been split into two sections.

Installing WordPress on Windows using SQL Server 2008 R2 Part 1 - This section will cover installing and configuring PHP and IIS 7.5.

Installing WordPress on Windows using SQL Server 2008 R2 Part 2 - This section will cover configuring your SQL Server and installing and configuring WordPress.


Setting up the Platform

As most people know you will need PHP installing in order to run WordPress. If you are installing this on a fresh Windows 2008 R2 server you will also need to make sure you have the Microsoft Visual C++ 2008 Redistributable Package (x86) installed before installing PHP. You will also need to make sure you have the IIS Web Server Role installed on your server. So the list of things to setup first are:

  1. Setup IIS Web Server Role on server. You can find more information at the following link on how to do this.'%20and%2070-68='2/installing-iis-7-and-above-on-windows-server-2008-or-windows-server-2008-r2 When installing the ISS Web Server role you will be prompted that the .Net 3.5 Framework will also need to be installed as a dependency. It may also be worth installing the latest .Net Framework as well.
  2. The second thing to do would be to install the C++ Runtime Package. You can download and install this from here. You will need to install the x86 version of this.
  3. The third thing you will need to do is install the SQL Native client on your machine. You can download and install this from the following link
  4. The next thing to do will be to download and install the latest version of PHP for Windows. Instructions are below for this.

Installing PHP

Firstly you will need to download the latest version of PHP for Windows. You can get this from the following links: or

I downloaded the VC9 x86 Non Thread Safe (2013-Jan-16 21:42:34) installer. The difference between Non Thread Safe and Thread Safe is basically to increase performance along side the FastCGI protocol setup in IIS. To find out more on this subject please read the following link

When installing accept the T&Cs and choose an install path.


It doesn't matter where but I used the default path. If you are planning to run multiple versions of PHP on the same server then it may be worth changing the path to incorporate a folder for the current version you are downloading and installing. Click Next

Select IIS FastCGI as the support protocol. FastCGI for IIS enables popular application frameworks that support the FastCGI protocol to be hosted on the IIS web server in a high-performance and reliable way. FastCGI provides a high-performance alternative to the Common Gateway Interface (CGI). CGI is a standard way of interfacing external applications with Web servers that has been supported as part of the IIS feature-set since the very first release. More information on this can be found here. Click Next.

Now you will have to select the PHP features you require.

I added all of the Script Executable and Extras features. The other features can be left as default. Click Next until the installation starts. Once finished we need to setup the SQL Server Drivers for PHP.

Installing SQL Server Support

This stage will allow you to setup all the support you need for SQL server and configure PHP for the WordPress install. The first thing you will need to do is download the correct SQL Driver for PHP. You can download the driver from the following link:

Download and save the SQLSRV20.EXE version to your machine in a directory of your choosing. Browse to the saved directory and run the EXE. You will be prompted with a security warning when running it so press to continue and the extraction will begin.

Agree to the licence Terms and Conditions.

Browse to a path to extract the Driver DLLs and click next.

Once you receive this message, click OK and browse to the directory you extracted the driver DLLs to. You should have the list shown below extracted to your directory.

The highlighted DLLs will be required based on whether you installed Thread Safe or Non Thread Safe versions of PHP. You will need to copy the highlighted DLLs to the ext directory of your PHP install folder. My path looked as follows C:Program Files (x86)PHPext. At this point you will need to update some PHP configs. But after doing some searching I found a tool that plugs straight into IIS 7.5 and allows you to configure PHP with ease. So at this point I recommend you download and install this plugin from the following link:

Download and install the correct version for your operating system. If you have IIS open, close it down and restart it. This will load the new plugin for PHP. Now we just need to setup the IIS website and register the driver for PHP.

Open IIS and browse to your sites folder. Right click and create yourself a new website. My site setup is shown below:

To create my test website I simply created a new Website through Visual Studio 2012 using one of the pre-packed templates. I then added a menu link to what will be my WordPress blog. So my link path looked like this "http://WordpressParent/Blog/". I then saved and built my project and copied it to my WordPress hosting machine and pointed my new website to it.

Next I needed to create myself a virtual directory to house my WordPress Blog inside my website. To do this right click on your new website and select "Add Virtual Directory". The properties of my directory looked like so:

Now we are done we just need to register the SQL Driver with PHP. We are going to do this by using the PHP manager through IIS. You can open this by clicking on your website and browsing to the PHP Manager under the IIS settings section.

Once you open the Manager for the first time it should detect your PHP installation automatically depending on where you have installed it. If it does not simply use the "Register new PHP version" link to browse the php-cgi.exe and register your installation. Also if this is the first time your registration has been accessed there will be a small warning about optimal configuration of PHP. Feel free to use the "View recommendations" link to sort this out and enable all the applicable recommendations.

Now we can register our drivers for SQL. To do this click on the "Enable or Disable an Extension" link to open the configuration window. You should now see the driver DLLs you copied to the PHP install directory in the Disabled section. Depending on the version of PHP you installed enable the correct driver. For example enable the drivers containing "_nts_" in the name if you installed the Non Thread Safe version of PHP. Now that we have completed this we have got SQL Server support enabled. But while we have the PHP Manager open we should do some other configurations before we finish.

Final Configurations of PHP and IIS

There are a couple of things that no-one ever covers in their posts about this subject and these things are what happens when you try to use your Blog. So these configs should help get rid of some of the problems you will face.

1.) Error Logging - If the user running your application pool in IIS does not have the correct permissions your error logging will fail. To sort this firstly we need to change the directory of the error logs. The default path is "C:Windowstempphp-errors.log". This will always cause problems with permissions so to resolve this lets change it to be hosted inside our website directory. This may not be suitable for some people using PHP but as we only want to use it to run WordPress this will be fine. To change the setting click the "Configure error reporting" link under the PHP Settings section.

I set my error reporting to production and set the path to be within what will be my WordPress blog directory.


2.) Application Pool Settings - Next we need to make sure that our application pool settings are correct as we need to run our website in the correct framework and with the correct permissions. I recommend using a domain account specifically setup to run your application pool and then assign this user permissions on the website directories. Then we need to make sure the target framework is .Net 4.0 or which ever Framework you updated on your host machine. Another thing to make sure is that your application pool is set to Integrated mode. to make any one of these changes simply right click on your application pool and select the "Advanced Settings" option. Change the required settings and click OK to commit your changes.


3.) Other PHP Settings - Final configurations you can make is to ensure that the correct logging level is set in PHP and that errors are not displayed in any of your PHP applications. These settings are not required but I recommend making them or to ensure they are set correctly. If you chose to setup your error logging for a Development Machine for instance these settings are very annoying. To make the changes click on the "Manage All Settings" link and update the display_errors = Off and the error_reporting to either E_ALL ^ E_WARNING or E_ALL & ~E_DEPRECATED. For more information on these settings please review the post at the following link .


4.) URL Rewrite Module - We will need to install URL Rewriting on our IIS machine for use with WordPress Permilinks. To do this go to the following link: and download the module. On a new machine you will be prompted to install the Web Platform Installer 4.5 before continuing. Install this and then re-try the URL Rewrite install. You will find that the Web Platform Installer takes over the install once it starts. Simply press next to everything and continue with the install.


OK, now we have done this we are ready to setup our database and install WordPress. These steps will be covered in the second part of this blog post which you can find below.

Installing WordPress on Windows using SQL Server 2008 R2 Part 2

Any questions?

If you need more information or have any questions just get in touch and we'd be happy to answer them for you.