Monthly Archives: January 2011

WordPress Windows 2008 Web Server R2 IIS 7.5 setup

I thought I would share a few important tips on getting WordPress 3.x to work properly – with PERMALINKS / SEO friendly URL’s.  It’s taken me a lot of trial and error to figure out the finer points, but assuming you can get it installed, these tips should help you get it 100% functional.

  1. to install, use the Microsoft Platform Installer 2.0, and let it do the work of installing PHP, WordPress etc.  IT IS FANTASIC!!! It will automatically setup PHP/FASTCGI for you and it is slick!  You can access the direct link to install WordPress on IIS here http://www.microsoft.com/web/wordpress/
  2. Secondly, I am going to make an assumption you are installing this as a subdirectory on your root site, such as www.mysite.com/blog.  If you are installing this to the root the same directions will basically apply but you’ll need to figure out which setting will need to be adjusted to put WP on the root.
  3. Third, we use a dedicated MySQL 5.x box, so we don’t install MySQL as part of the MPI 2.0 install (from step 1).  If you don’t already have a MySQL server you’ll need to let it install that as well, or make a new empty database on your MySQL box and use that info as part of the install process.  For security and speed reasons, a dedicated server for MySQL is the best choice, but not everyone has the resouces to permit a dedicated server.
  4. Under IIS 7.0 or 7.5, make sure you have downloaded and installed the free URL REWRITE 2.0 add-in for IIS.  This is a free download here: http://www.iis.net/download/urlrewrite
  5. PERMALINKS.  Once you get WP installed and are able to login to the admin interface, it’s pretty simple to get permalinks running.
    1. in the WP admin, go to SETTINGS->Permalinks.  We chose to use the “DAY AND NAME” setting.  Any other setting is your choice.  Pick a setting and click save changes.
    2. make sure you have a web.config file in your /blog/ subdirectory. 
    3. here is what your web.config file should look like – customized just for WP 3.0 in the /blog/ subdirectory (below).  (Download a ZIPPED copy of my file here)
    4. <?xml version=”1.0″ encoding=”UTF-8″?>
      <configuration>
        <system.webServer>
          <httpErrors errorMode=”Custom” />
          <rewrite>
            <rules>
             <rule name=”Main Rule” stopProcessing=”true”>
              <match url=”.*” />
              <conditions logicalGrouping=”MatchAll”>
               <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>
          <defaultDocument>
            <files>
              <clear />
              <add value=”index.php” />
            </files>
          </defaultDocument>
        </system.webServer>
      </configuration>
    5. Save this into your web.config file – this is all you need for WP running in the /blog/ directory.  Once you replace your file with this one your permalinks should work flawlessly.
  6. Troubleshooting.  One easy way to troubleshoot things with your WP install, is to enable DETAILED errormode.  To do this, edit your web.config file within the /blog/ folder and change just the one line above to this <httpErrors errorMode=”Detailed”/>  Of course when you are all done and going live with WP, change that line back to “Custom”
  7. Fixing permissions so that images/media/files uploaded via WordPress will properly render.  This is the fix for the infamous “500” error that is thrown when your server has wrong file permissions and the visual result is all the images you uploaded are “broken images” and won’t display. Also called HTTP Error 500.50 – URL Rewrite Module Error when you have Detailed errors on.
    1. Don’t sweat it, I will save you HOURS of time on this one.   Thanks to the article I found here after HOURS of tracking this issue down, this problem is caused because PHP first uploads the document to a temporary directory (by default C:\Windows\Temp), and then moves it from that directory to the actual /blog/wp-content/uploads/ subdirectory.  What happens is that because IIS does not have any permissions to your “C:\Windows\Temp” directory, when the file is uploaded there, then moved by PHP, the file inherits NO permissions.  So when IIS trys to serve out that file from your /blog/wp-content/uploads/subdirectory it throws a 500 error and that is actually a permissions error.
    2. The solution:  on the Windows\Temp folder, grant “modify” permissions to both IUSR and {servername}\IIS_IUSRS user accounts. 
    3. Now when you upload files via PHP and PHP moves them to the correct directory, the files will have the correct permissions and can be accessed.
    4. Important note #1:  If you already have uploaded files and are getting the dreaded broken images issue, go to the /blog/wp-content/uploads/directory and replace/update the permissions to add access for both user accounts noted above.  That will solve that issue.
    5. Important note #2: as with any change off the defaults for Windows, you do this AT YOUR OWN RISK.  It’s up to you if you want to grant the Windows\Temp directory permissions for those two accounts.  If you don’t PHP won’t be able to upload without the 500 issue (unless you move the PHP temp folder elsewhere and grant those accounts access to the other folder).  Do these changes at your own risk… I cannot and won’t take any responsiblity for your systems.  Please know what you are doing.
  8. Another site with good info on WordPress/IIS installs is here

Best of luck on your Windows 2008 R2 IIS 7.5 WordPress install. We use it here and it is fantastic!