WordPress on Windows Server 2012 with IIS 8 and SQL Server 2012

Yesterday I decided to install WordPress for my new blog, both because it seemed like good product for the job and also to get some experience in running it (and thus also PHP) on Windows Server 2012 with IIS 8. There are some good resources scattered around the web, but none seemed up to date, so I decided to share my notes from the install on here. I’m assuming you already have Windows Server 2012 and SQL Server 2012 installed.


The configuration of IIS 8 is quite easy: you just enable the Web Server role through Server Manager. Just to be complete, the screenshot below shows the options I currently have installed, but keep in mind that I’m also running ASP.NET on my server.

Web Server (IIS) Role configuration

I also highly recommend you install PHP Manager (http://phpmanager.codeplex.com/) as it will help us in enabling/disabling PHP extensions from within IIS Manager later on and provides an easy way to access php.ini as well.


To make things easy, you can install and configure PHP quite easily using the Microsoft Web Platform Installer. When you run the Web Platform Installer (Web PI), you can do a quick search for “sql php” and it comes up a few results. When you select “Microsoft Drivers 3.0 for PHP v5.4 for SQL Server in IIS”, which is what we need, all other prerequisites will be automatically installed as well as dependencies (PHP and URL Rewrite for IIS).

After Web PI finishes, you will have PHP installed and configured for use in IIS. Time to do a little test to see if everything is running smoothly. Create a new file under C:\inetpub\wwwroot\ (or wherever your Default Web Site is pointing to) named test.php with the following content:

This will output information about your PHP configuration (ref: http://php.net/manual/en/function.phpinfo.php).

Time to try it out: navigate to the page (likely http://localhost/test.php). If you are greeted with a screen with purple blocks of information about your PHP configuration, you’re all set and you can skip ahead to the WORDPRESS INSTALLATION section. Chances are you’re going to be greeted with an IIS 403.1 error screen, however, which is due to the fact that the user account that IIS is currently using for the anonymous access to your site doesn’t have the proper privileges to access your wwwroot (or equivalent) folder on disk. This is solved quite easily by granting this user (called IUSR by default) access to the wwwroot folder through Windows Explorer or your other favorite method.

Granting IUSR proper permissions

Retry and bask in the glory of the phpinfo() output!


Now we can start downloading the actual WordPress files and start the installation. First off, grab the latest version (or the version of your choice) of WordPress. We will also need the WP Db Abstraction plugin. After downloading, unblock and unZIP both files in a folder under wwwroot (or your Web Site’s location). Installation of the WP Db Abstraction plugin is quite easy, just follow the steps outlined in the readme.txt:

  • Upload wp-db-abstraction.php and the wp-db-abstraction directory to wp-content/mu-plugins. This should be parallel to your regular plugins directory. If the mu-plugins directory does not exist, you must create it.
  • Put the db.php file from inside the wp-db-abstraction.php directory to wp-content/db.php
  • Visit $your_wordpress_url/wp-content/mu-plugins/wp-db-abstraction/setup-config.php to generate your wp-config.php file

Before you perform the last step, though, go to IIS Manager and enter PHP Manager (it’s located on the Features page of your server under IIS). Scroll down and click the “Enable or disable an extension” link. You need to make sure that php_pdo_sqlsrv.dll and php_sqlsrv.dll are both enabled. You can also go ahead and disable the *mysql*.dll extensions. Here’s my list of enabled extensions:

Enabled PHP extensions

Now we can visit the setup-config.php page as outlined above. The steps here are quite straightforward, so I’m not going to walk you through them. You will need to create a user on your SQL Server 2012 installation with SQL Server authentication that has access to a database that you also need to create to use for your WordPress installation. If you need help, follow the instructions outlined at step 2 on http://wordpress.visitmix.com/.

One note about this process: I had some issues when choosing the default selected “SQL Server using MS PHP driver” and went with the “PDO SqlSrv” option the second time to eliminate these issues.

If the wizard has trouble automatically creating the wp-config.php file, you can either choose to give IUSR write permissions on the folder you created to hold all your WordPress files or you can manually create the file under that folder and paste the output you see on screen in there (I chose the latter). After the wp-config.php file is created, you can start the installation of WordPress by clicking the link on the bottom of the page you’re on.


After the install, which should only take a minute tops, you are now ready to log in to your WordPress admin dashboard and start configuring it how you’d like. As you can see, there’s a sample post and comment already waiting for you. If your experience is anything like mine, you will notice that when you navigate to the Posts -> All Posts option on the top left of your dashboard you won’t actually see these posts in the list. It took some hunting around the web to figure this out, but apparently there’s a line in the translations.php file of the WP Db Abstraction plugin that’s causing this (thanks to tm3ister on http://sourceforge.net/projects/wp-sqlsrv/forums/forum/1124403/topic/5004241 for figuring this out!). The solution is to manually edit the translate_limit function in the mu-plugins/wp-db-abstraction/translations/sqlsrv/translations.php file:



And voila, your posts will now show up.

The last thing we’re going to configure is Permalinks (or pretty URLs) for our posts. When you navigate to Settings -> Permalinks on the admin dashboard, you’ll see some options to rewrite URLs to be more human and search engine friendly. For now, select Custom Structure and enter /%year%/%monthnum%/%postname%/ in the text field and hit Save Changes. The last step is to create a web.config file in our WordPress folder to rewrite the URLs according to this scheme with IIS URL Rewrite. Create a new web.config file (if you don’t have one already) in the folder you installed WordPress to and copy in the following:

You’re now all set to use WordPress on Windows Server 2012 with IIS 8 and SQL Server 2012!


Just a few more comments that might help out when you’re hitting some of the issues I hit:

  • If you upload an image to the Media Library, but cannot access it due to a 500 error, it might be because IUSR doesn’t have write permission to PHP’s temp directory (default C:\WINDOWS\Temp). Granting IUSR Modify permissions to this folder will solve that. Source: http://forums.iis.net/t/1159252.aspx/1
  • When updating or downloading themes/plugins, you might get an error about a directory not existing or not being writable. Adding the following in the wp-config.php in the root of your WordPress installation will solve that: define(‘WP_TEMP_DIR’, ABSPATH . ‘wp-content/’);. Source: http://royaltutorials.com/destination-directory-for-file-streaming-does-not-exist-or-is-not-writable/
  • If you want to install a theme that’s larger than 2M through the admin dashboard’s upload mechanism, you might get an error that it exceeds PHP’s max upload size. Open php.ini and change the upload_max_filesize value to something higher (e.g. 5M).

That’s it for me. If I missed something or if you spot a mistake, let me know in the comments!

Pin It

44 thoughts on “WordPress on Windows Server 2012 with IIS 8 and SQL Server 2012

  1. Thanks Nitin – this absolutely worked for me. Just opened cpanel, found the file, edited it, and it worked. (I commented out the previous line so I can change it back if needed). Changing permissions on other directories did not work for some reason.

    Any implications with leaving the new line in there on a go-forward basis?

  2. Hi, I am getting the following error when I deployed my wordpress on remote hosting after setting on my local host

    Warning: mysql_free_result(): supplied resource is not a valid MySQL result resource in D:\Hosting\5158804\html\demo\wp-includes\wp-db.php on line 1125

    any solution for this ?

    • Good point, post has been edited.

      Not sure why you’re getting the error installing PHP Manager, haven’t seen that one. Could you try posting on the IIS/WebPI forums?

  3. I recently set up a server with Microsoft Windows Server 2012 and I have several PHP websites installed that all work as they should except for one major flaw: I cannot get web file uploads to work AT ALL. I have looked and looked and I can only find the same answers that even you have provided.

    In a specific example, i am trying to upload a new theme to an installation of wordpress using the admin panel. each time i try to upload a file i am confronted with “unable to create directory wp-content/uploads/2013/05. is its parent directory writable by the server?”

    “IIS_IUSERS” has permissions on C:\Windows\Temp
    I even changed the temp directory in php.ini, created the folder C:\inetpub\temp\uploads, and gave it IIS_USRS modify permissions and i STILL cannot get files to upload to the server.

    So way passed aggravated with this issue. If you have any advice please let me know.


    • Hi Jeremy,

      Sounds like you need to grant permission to your wp-content folder and not your temp folder. Have you tried that as well?

      • I cannot change the permissions of the public web folder. As far as I can tell, all folders inside of C:\inetpub\wwwroot are automatically given modify rights to IIS_IUSRS

  4. Hi,
    Did anyone get the import plug-in to work with this full Microsoft setup?
    I hoped that I could import my old MySQL blog to this.

    What about multi-site feature?


  5. hi friends i have create one blogs site local server and it move to windows iis server after i have not create any other post and page.
    my directory is not writteble but i have add to file code

    – If your web.config file were writable, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your web.config file. Click in the field and press CTRL + a to select all. Then insert this rule inside of the //// element in web.config file.

    – The following permalink rewrite code should be included in your .htaccess file

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    plz help me fast

    thanks prakash

    • On IIS you’ll use URL Rewrite instead of .htaccess. The actual URL Rewrite rules are outlined in my blog post toward the end of the post!

  6. Hello Rajen,

    Thanks for the post, but I get stuck after filling the database settings. After I hit the commit button I get a blank page and nothing happens. Even if I enter wrong usernames I don’t get an error. Just a blank page…???
    (I checked access rights for IUSR, Prereqs and so on like 10 Times… Everything looks good. Also test.php is working)

    Do you have any hint for me?

    • Hey Markus,

      If I remember correctly, I hit the same behavior on my first try. I’m not sure how I solved it, but I fear it was a re-install from scratch. Perhaps you can ask on the official WordPress forums if they know what the cause for this could be. Sorry I can’t help you any further!

  7. Thanks for the article, in meantime i want to ask you something about my problem.
    i did all these steps successfully, my site is running now but when i try to do last step in my web.config file(copying the rewrite rules) my site comes up with internal server error 500. any ideas ? thanks again.

  8. Hi Ugur,

    Can you try checking IIS logs for a more specific error? A HTTP 500 error is a generic error that doesn’t really indicate anything. You could also try enabling IIS to show errors locally to get a better idea of what’s wrong.

  9. This is a good tutorial but I’ve already been down this road and would advise against. I was pleased when I found out it was possible as we mostly deal with .NET and MS technologies so it would have been very convenient to have all our databases on one platform. You’ll start hitting problems when you install plugins as they are all developed with LAMP in mind – it just becomes a pain to have to fix tweaks here and there. We now host a lot of WordPress sites and it’s simply too risky using something that isn’t supported. I just checked the link and the project hasn’t been updated in nearly four years. If you’re just using this for your own blog it might be okay but in a production environment you’re asking for trouble.

    That’s my opinion anyway 🙂


  10. blah I get through the DB config and setup, then go to install WordPress, answer the questions on ?Step1… Click Install, screen clears, big white box with WordPress logo appears.. Now what? Is there suppose to be more displayed here? If I try to re-setup the site it says it is already configured and takes me to the admin login page. Trying to login with the password entered in the WordPress Step1 setup, fails.

    The tables get created in the SQL DB…


    • Hey Dane,

      I think I actually hit that behavior once as well. Clearing the DB and going through the setup steps again seemed to solve it if I can remember correctly, not really sure what went wrong that time.

  11. I’m running into the same issue Ugur saw. I get to the setup-config.php?step=2 and it loads a 500. Anyone else see this behavior? Do you have a sample WP-Config.php you could post? I’d like to try a manual setup, but the wp-config.sample.php has only MySQL connection strings, and I’m not sure what the syntax should be in the wp-config file for a full SQL (not SQLExpress) install would be.

    Any help would be greatly appreciated.

  12. Hi,
    I have installed word press in my window server.Everything working fine except page edit and create.it shows empty page can you please help me on this?

  13. What WordPress version did you (Rajen) use? ( currently using 3.8)
    My WordPress installations stops after insterting the credentials ( step is a blank page)
    and i don’t know how to proceed.
    Any idea or suggestions which version of wordpress to use?

  14. Pingback: How to install WordPress on Windows Server

  15. Mmmm..I’ve spent ages today trying to get a localhost IIS8 WordPress setup on my Win8 PC. Issues range from not being able to update things (eg theme or plugins) automatically (FTP issues and permissions issues) to media uploader not uploading image files. I haven’t yet fixed the image upload problem and I’m not impressed with this poor state of affairs! WordPress and Windows should work better together (please don’t tell me to install WP with WebPI either, as that refuses to access the database too!…aaaaargh….). WordrdPress webdev on Windows…mmm…aaaargh!!! 🙂

  16. Will it be good if I use Web Platforms Installer in IIS Manager in Windows 2008 ? My requirement is to install php & mysql. The idea is to run both asp.net & php applications together and serve it from the same server. can you please guide ?

    • That shouldn’t be a problem, WebPI makes installing PHP and MySQL very easy, so you can definitely do that! I recommend also installing the PHP Manager in that case, for easier management of PHP on IIS.

  17. Rajen,

    I’ve been fighting with the installation for couple of days now.
    My server is a Windows 2012 R2, using IIS8.5, PHP 5.4 and trying to point to my SQL Server 2008.
    I check all the .dll, and if I don’t removed the MySQL.dll the configuration will loop between the abstraction setup-config and the wp setup-config files. If I remove (disable) the MySQL.dll php extensions I will have this error
    “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.”

    Any suggestions??

    • Hi Sofia, I’m afraid it’s been quite a while since I’ve set all this up and I can imagine things have changed with Windows Server 2012 R2 and IIS 8.5. The behavior you’re describing doesn’t ring any bells with me, so I think your best bet will be the WordPress forums.

  18. Oatlhotse Modisane May 19, 2017 at 6:43 AM - Reply

    Can WINS server function properly without DNS server on server 2012 and what has really improved about it from server 2012 to server 2012R2?

  19. Unfortunately, NONE of the sites that I’ve visited over the past 3 days address the very frustrating “too many redirects” issue as it pertains to running WordPress under IIS 8.0 on Windows Server 2012 R2. Note that there is NO .htaccess file, there is only a wp-config.php file. I have searched and searched and searched for a solution to this issue, with zero luck thus far. Please note that the ADMIN area (for WordPress), works fine. It is only when I try to fire up the site itself that this “too many re-direct” issue comes up. In fact, many of the sites I’ve visited state that the issue is caused by “the hosting company.” Unfortunately, I AM the hosting company, so this does not help me. Please help! This is driving me crazy!

  20. I am having this problem “Your PHP installation appears to be missing the MySQL extension which is required by WordPress” when I’m upgrade the php from version 5.6 to 7.2. Turns out that mysql extension is no longer supported in php version 7.2. It is now using mysqli extention. I am using old version of wordpress which still using mysql extension so the problem existed. So what I did is upgraded the wordpress to the core. I used the latest version of wordpress and used filezilla to put the new version to the site. I only overwrite the folder wp-includes and wp-admin and replace all the files in the root folder with the new files

Leave a Reply

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