Debriefing

We’re a Windows shop here.  So when the topic came up from our Application Developer to test out WordPress as the platform for our next website we knew that it would be the unconventional approach to doing things.  But, I’m always up for the challenge.  Since I could find no concise guide to getting this done I figured I’d share my approach with you all to ease some of the pain.

The Environment

  • The server is a VM running Windows Server 2008 R2 which is of course 64-bit.  This is now the standard O/S platform for all newly created servers in our environment.
  • The database server will not be SQL Server Express as we have a VM running SQL Server 2008 SP1 in our environment.  This guide is written for those who have this setup as most of the guides that you find around the web assume that installing SQL Server Express locally is acceptable.
  • Keep in mind that this installation is intended for a development environment and not for production.  It’s safe to assume that additional security measures will need to be taken before employing IIS, WordPress or any of the other components in a production environment.

Install IIS 7.5

The first step in the process is to install the web server–IIS 7.5.  The configuration options that we select will take into account that we will later need to install PHP, WordPress and other components on the server.

  1. Open Server Manager.  Click Roles, then Add Roles.
  2. In the Add Roles Wizard click Next to skip past the first screen.  At the Server Roles step select Web Server (IIS).  Click Next, then Next again past the introduction.
  3. At the Role Servicesstep select the following keeping the default selections in tact:
    • HTTP Redirection
    • Application Development (the entire node)
    • Basic Authentication
    • Windows Authentication
    • Digest Authentication
  4. Click Next then Install.
  5. Once installation is complete close Server Manager and re-open again to refresh it (just a little something I do out of habit because sometimes Server Manager doesn’t update like it ought to).
  6. In Server Manager go to Roles > Web Server (IIS) > Internet Information Services (IIS) Manager.  I usually click the Show/Hide Console Tree button at this point.
  7. Within IIS Manager select the Server > Application Pools.  Select Set Application Pool Defaults from the Actions pane on the right.
  8. Change Enable 32-bit Applications to True.  This is important as there is no stable release of PHP that runs on a 64-bit Windows O/S.

Install PHP 5.3.5 for Windows

Next we need to install PHP 5.3.5 for Windows.  We want to use FastCGI for its performance advantages.  So this process will enable this functionality in our environment.

Download and Install PHP Manager

  1. Go here: http://phpmanager.codeplex.com/ to download PHP Manager.  Be sure to download and install the x64-bit edition.

Download and Install PHP 5.3.5 for Windows

  1. Go here: http://windows.php.net/download/.  Under VC9 x86 Non Thread Safe, select the Installer since this is a fresh installation of PHP; to download.
  2. Run the Setup Wizard hitting Next at the first screen and accept the EULA.
  3. Change the installation directory to C:\PHP-5.3.5 so as to provide flexibility if you wish to run multiple versions of PHP on the same server.
  4. At the Web Server Setup step select IIS FastCGI.
  5. (Optional) – Install the following features:  Script Executable, Register *.php files to open automatically and PEAR Install.
  6. Click Next then Install to complete setup.
PHP Manager

PHP Manager

Configure PHP 5.3.5 Using PHP Manager

  1. Go to IIS Manager and select PHP Manager.
  2. Under PHP Setup select View Recommendations.
  3. Select all of the recommendations and hit the OK button.
  4. (Optional) – Select PHP Error Reporting and select Development Machine and change the location of the error logs.

Install a Few Additional Components

Now with PHP installed there are a few recommended additional components that need to be downloaded and installed.

Download and Install URL Rewrite

  1. Go here: http://www.iis.net/download/urlrewrite and download the x64-edition of the URL Rewrite Module 2.0.

Download and Extract SQL Server Driver for PHP 1.1

  1. Go here: http://bit.ly/dYe5W2 to download the executable.
  2. When prompted for a location to place the extracted files browse to C:\PHP-5.3.5\ext which is the PHP extensions folder.

Import Extensions into PHP Using PHP Manager

  1. Go into PHP Manager and select Enable or Disable an Extension.
  2. Select php_sqlsrv_53_nts_vc9.dll and click Enable in the Actions pane.  This allows for PHP to communicate with a SQL Server database.

The Time Has Come to Install WordPress!

Finally, we’ve arrived at the point where we install WordPress.  There are a few things that need to be done within IIS and with folder permissions but this should be the easy part.

Prepare IIS for the WordPress Install

  1. Go into IIS Manager and stop the Default Website as I wish to install WordPress in its own folder.
  2. Go to the C:\inetpub\wwwroot folder and create a folder called wp-sqlsrv.
  3. Right-click on the folder and select Properties.
  4. Go to the Security tab and grant the local IUSR account Write access to the folder.
  5. Back in IIS Manager Add a Website called wordpress (or whatever you’d like to name it) with the Physical Path pointing to the folder that we just created.
  6. In the Bindings section create any IP Address, port or host name bindings that are appropriate for your environment.  I just entered the host name of the server for starters.
  7. Creating this website creates an application pool of the same name.  Go into Application Pools and select the wordpress application pool.
  8. Select Advanced Settings and under Identity select Custom account.  I enter the username and password of an account with domain admin rights just for the installation of WordPress.  I will change this back post-installation.

Prepare SQL Server 2008 for the WordPress Install

  1. Launch the SQL Server 2008 Management Studio and connect to the database server in your environment.
  2. Go to Security > Logins and create a New Login (something like wpuser).
  3. Select SQL Server Authentication and decheck Enforce password expiration.
  4. Leave everything else as the default and click the OK button.
  5. Go to Databases and create a database called wordpress (or whatever you desire) and make the user that we just created (e.g. wpuser) the Owner of the database.

Download and Install the SQL Server Native Client

  1. Go here: http://www.microsoft.com/web/downloads/platform.aspx to install the Web Platform Installer.
  2. Search for SQL Server Native Client and Install.

Download and Install WordPress on SQL Server

  1. Go here: http://wordpress.org/extend/plugins/wordpress-database-abstraction/ and download the WP Database Abstraction Plugin.  Please be sure to read the Other Notes section before using this plugin as there are limitations and things that you will need to be aware of when it comes to the abstraction plugin interacting with other plugins.
  2. Extract the .zip files to the root of the C:\ drive then copy the contents of the wordpress folder to C:\inetpub\wwwroot\wp-sqlsvr.
  3. While in the root of the wp-sqlsvr folder create a web.config file with the following contents:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <httpErrors errorMode="Detailed"/>
    </system.webServer>
    </configuration>
  4. Browse to the website and select Create a Configuration File.
  5. Go through the configuration wizard for WordPress setup and be sure for Database Type to select SQL Server using MS PHP Driver.
  6. When you are finished setting WordPress up and the initial site launches, change the web.configfile to this to activate URL rewrite:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="wordpress" patternSyntax="Wildcard">
    <match url="*"/>
    <conditions>
    <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>

It’s A Wrap

That should do it.  The database should configure itself and you’ll be prompted to enter the admin account username and password for WordPress and that should be all that is needed.  I hope this concise guide was helpful.

About these ads