WordPress on Windows with a MSSQL database

Project Nami

While randomly searching the web, I found Project Nami. Project Nami is an effort to make WordPress installs available on Windows with a MSSQL backend for the database. It’s main focus is being able to run WordPress on Azure, but it works pretty decent on local IIS installations as well.

Setting things up was surprisingly easy. All you’d need is;

  • A PHP installation that’s working on IIS (which you can find tons of tutorials on how to).
  • A MSSQL install (anything higher or equal to MSSQL 2012,Express also being supported).
  • The PHP MSSQL driver. Unzipped in your PHP extension directory.
  • The IIS Rewrite module.
  • The Project Nami files unzipped in a web accessible directory.

You need to make sure you load the PHP MSSQL driver extensions in the php.ini. After doing that and restarting IIS you’re good to go. You can just access your localhost and setup WordPress as you’re used to.

Plugins might cause troubles…

When I was playing around with a local install, I noticed a lot of plugins out there have issues with Project Nami. Some of them just don’t work while others will completely screw your WordPress installation. Some caution is adviced when installing and enabling add-ons.

Some more configuration

Although not strictly necessary, it’s probably recommended to do some tweaking to your IIS WordPress install. Adjusting the web.config file (the counterpart of Apache’s .htaccess). Of course all these settings can also be achieved through the IIS Manager application. Below you find an example web.config file I’m using currently to test things out.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering>
                <denyUrlSequences>
                    <add sequence="config.php" />
                    <add sequence="readme" />
                </denyUrlSequences>
                <fileExtensions>
                    <add fileExtension=".sql" allowed="false" />
                    <add fileExtension=".ini" allowed="false" />
                    <add fileExtension=".bat" allowed="false" />
                    <add fileExtension=".cmd" allowed="false" />
                    <add fileExtension=".ps1" allowed="false" />
                </fileExtensions>
            </requestFiltering>
        </security>

        <directoryBrowse enabled="false" />

        <caching>
            <profiles>
                <add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
                <add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00:00" />
            </profiles>
        </caching>

        <defaultDocument>
            <files>
                <remove value="index.php" />
                <add value="index.php" />
            </files>
        </defaultDocument>

        <rewrite>
            <rules>
                <rule name="Main WordPress Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <!-- add input="{REQUEST_URI}" matchType="Pattern" pattern="^/wp-admin/" negate="true" /-->
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Be First to Comment

Leave a Reply

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