Web Deploy

Deploy WordPress to Windows 2008R2 – Part III

Part 3 – Fine tun then install a fresh WordPress for testing

We need two IIS Extensions for proper working of IIS 7.5 with WordPress, they are URL Rewrite and Wincache extension for PHP.

  • URL Rewrite
    This extension is important if you want to have Pretty Permalinks (and who does not?) in WordPress. If you don’t know what I am writing about, read here about Permalinks in WordPress (or directly from WordPress).
    Point your web browser to http://www.iis.net/downloads/microsoft/url-rewrite, and by the end of that web page, select one of the x64 variants, according to your language. For English, I downloaded rewrite_2.0_rtw_x64.msi.
    Install URL Rewrite 2.0, then follow the instructions on the above referenced links to set the web.config manually and you will be done. Note: WordPress 2.8 and later will update web.config for you if you grant write permission to web.config file (but grant temporarily only!).
  • Wincache
    To download Wincache, point your web browser to http://www.iis.net/downloads/microsoft/wincache-extension. Don’t be scared by the apparent abandon of the page, it comes as no surprise that Microsoft does not care much about PHP since this competes directly with their own .Net product. Anyway, around the bottom of the mentioned page you will find a link to WinCache 1.3 for PHP 5.4 – x86. Wow, this URL takes us to Sourceforge, so Wincache is not really a Microsoft product. 😳
    To install Wincache, run it to unzip the content to a folder then copy php_wincache.dllto the PHP extensions folder (C:\inetpub\php\ext). Edit php.ini and change or add the following:

    • In the dynamic extension section add:
    • Search for the line session.save_handler = files and  replace it with the line session.save_handler = wincache
    • Make a folder under the PHP tree, call it phpsessions, give Users and IIS_IUSRS permissions to read, write, modify and delete on that folder. Add the following line to php.ini:
      session.save_path = “C:\inetpub\php\phpsessions”
    • Restart IIS then launch phpinfo.php again (see Part II) to confirm that Wincache is inserted in the system

We are done with the tuning, time to go to the WordPress website and download the latest WordPress distribution, which was 3.4.2.

Important: Here, installing WordPress is only for illustration purposes because, as you will see in the final Part IV of this tutorial, we don’t need WordPress previously installed when publishing  to a web server a website already developed  in our home or office computer.

So, place the WordPress distribution in a suitable place within the inetpub folder, such as inside wwwroot, then unzip it. The whole WordPress will be unzipped to a subfolder of wwwroot, very appropriately called wordpress. If what you wanted was build a new website exclusively based on WordPress you could have placed the WordPress distribution directly inside the inetpub folder (or anywhere), unzip, rename the obtained wordpress folder then set that folder as a website from within IIS.

Before we can run WordPress, we need to do a few things.

  1. In IIS Manager, select the Default Web Site. Double-click Default Document, select Add from the right pane and add index.php to the default documents list.  Move index.php to the top of the list.
  2. To set up a mySQL database, download phpMyAdmin. The release I got was Extract the distribution to C:\inetpub\wwwroot\phpmyadmin. Navigate to http://localhost/phpmyadmin, type root for user name and the password should be the same used when you set up the mySQL software (Part II of this tutorial). Then Create a New Database, giving it an appropriate name (like “wordpress”). Collation should be set to utf8_general_ci.
  3. In the wordpress folder, rename wp-config-sample.php to wp-config.php. Edit wp-config.php with Notepad (or similar). If necessary, change the line define(‘DB_NAME’, ‘wordpress’) replacing wordpress with the name of the database chosen in step 2 above. Change the lines define(‘DB_USER’, ‘wpuser’) and define(‘DB_PASSWORD’, ‘yourpasswordhere’), using the user name and password for the mySQL database. All this procedure has been utterly simplified, but we are now ready to launch the WordPress test website.
  4. Point your browser to http://localhost/wordpress and you should see the WordPress installation welcome page.
(to be continued soon)

Deploy WordPress to Windows 2008R2 – Part I

Part 1 – Preparing the Windows 2008R2 Server

This is the first of a total of four posts about deploying Wordpress to a Windows 2008R2 remote server.

The matter is not straightforward for a few reasons:

  1. It is not easy to troubleshoot WordPress issues on Windows. Most WordPress gurus are of no help here because they have no experience using WordPress within Windows, as simple as that.
  2. Dealing with Windows 2008R2 deserves a long article of its own, as you may suspect.
  3. Tools from Microsoft, like Webmatrix and Webdeploy do not contribute at all to your knowledge. What I mean is that you follow the instructions, if something goes wrong you have no alternative but search forums and blogs, in other words use Google. So, you should resist with all your strengths in embarking into the easy road of doing things with click-once tools. That said, beware that for this series of posts I used WebMatrix in my Windows 7 development box, it was not a true time saver for me, but I followed the route most WordPress for Windows developers use, in order to make the situation more real.

So, imagine you have WebMatrix installed in your Windows 7 home or office computer, and developed a great WordPress website with it.  Now, the time has arrived to publish that amazing site to your web server lodged in a Windows Server 2008R2 (dedicated, VPS or cloud) located somewhere in the World. You can use FTP, right? Unfortunately, FTP solves only part of the problem because WordPress sites store the real content and most of the configuration in a mySQL database. Without the mySQL database your site is just a bunch of templates, or so it looks. So, you must FTP the database as well, right? Unfortunately not. Here Microsoft proposes the use of Web Deploy, but I was never able to use it properly. Web Deploy has many caveats with WordPress, one of them is that it can’t fix URLs except in the simplest of cases. Let’s move on without Web Deploy!

As a side note,  for people wondering why we are writing about dedicated, VPS or cloud servers instead of shared web hosts. Nowadays, lots of people have their own virtual servers because prices are low, and less and less people use slow shared web hosting for professional and corporate purposes. For instance, Amazon offers you, totally free during one year, a full fledged Windows Server 2008R2 (64-bit, of course) including a fair amount of bandwidth. Do you believe on this? Better you do, I will be using one for this article. Look at the image below:

So, you got a fresh installation of Windows 2008R2, like the one I got after I subscribed for my free micro EC2 at Amazon, then you had to go through the initial configuration steps, like Date and Time Settings, Keyboard selection, change the Computer name (not compulsory but recommended), and a few others. One thing I always do on new machines is configure the folder options in Windows Explorer, because I enjoy look at things as they are. Under the Organize menu of Windows Explorer, select Folder and search Options, then in the View tab, check “Show hidden file, folders and drives”, uncheck “Hide empty drives in the Computer folder”, uncheck “Hide extensions for know file type” and uncheck “Hide protected operating system files (Recommended)”. All right, I would never feel good until I completed this step.

But there is more!

  1. Now, launch Server Manager and add the role for Web Server. You may well select every Web Server service role or leave aside the ones you are sure you will never need, like let me say IIS 6 Management Compatibility, IIS Hostable Web Core,  Clienet Certificate Mapping Authentication. Make sure you do not forget to add the CGI role, this is very important to our purpose.
  2. Now install Filezilla (last version at the time of this writing was 0.9.41). Of course, you can install another FTP server, but Fillezilla is probably the best and the price could not be better. If you are indeed using the free Amazon EC2 box I mentioned above you will spend some time learning how to open ports through the perimeter firewall. It is not very easy easy, and by default only the RDP port is open. Anyway, this is home work. As a hint, consider opening the following TCP ports through the perimeter firewall: 21, 25, 80, 110, 1433, 3389 (RDP, already done) . If you want to have a DNS server there consider opening UDP port 53. If you want to be able to ping the server consider allowing Echo Request ICMP packets to pass through. Note: Amazon EC2 boxes are quite good and fast, but for a production server you will need more than what is supplied with the free tiny box and then costs climb pretty fast because you pay for everything. My cost estimate for a production web server installed on the small model (above tiny) will be around $80.00 per month in Amazon. For this reason I keep all my production servers with Burst, I pay less than $24, have 2.5 GB RAM, 2.5 GB memory and 100 GB hard disk.  But remote desktop to Burst is not as fast as to Amazon EC2 and server takes longer to boot, these are the real differences between cloud and VPS.
  3. Now launch the Windows Firewall Control Panel, enter an exception for Filezilla Server, add new Allow rule (Public/Domain/Private) for port 21 TCP. This should be enough, in most cases, to allow you to connect to Fillezilla Server from the Internet in “Active Mode” (I usually prefer this mode). For more about Active versus Passive FTP check this URL: http://slacksite.com/other/ftp.html. While we are configuring the Windows Firewall, add a Ping Echo Request rule, otherwise server can not be pinged from the internet.
  4. At this point you may want to disable the Enhanced Security from Internet Explorer (or alternatively, look for another internet browser). Disabling enhanced security is done as explained here: http://www.win2008r2workstation.com/disable-internet-explorer-enhanced-security/

This completes the preparation of our Windows 2008R2 Server.

(continues in Part 2…)