Apr. 24th 2011
This site now had a WordPress blog beside the Tomcat application server that runs TrailHunger.com itself. The setup was a little complex so I will detail it below.
My aim in setting up these blogs was to provide some quality content so that people share the content and Google sends visitors to the site. Therefore, I wanted to setup the blogs to be below the TrailHunger.com domain.
WordPress runs on PHP and typically uses Apache as the webserver. The original configuration of Tomcat had Tomcat listening to ports 80 and 443 and Apache wasn’t used at all.
I have just started using Opscode Chef to manage my infrastructure. I started with the cookbook for WordPress as that would do most of the work for me. I modified the cookbook to:
- Install into /var/www/blog so that the resulting blogs would be at www.trailhunger.com/blog
- Install WordPress 3.1.1 instead of the default 3.0.x
The blog-server role is this:
name "blog-server"
description "Wordpress Blog Server"
run_list(
"recipe[apt]","recipe[trailhunger::blog-server]"
)
default_attributes ( {"mysql" => { "server_root_password" => "password" }, "wordpress" => { "version" => "3.1.1", "checksum" => "aa2ea71a34596a6d53c653c00a549e2abd190a7cb3e80812e63b6e9444500a9b", "dir" => "/var/www/blog" }})
Because we are now using Apache as the front end server we need to communicate from Apache to Tomcat. The way to do this is to use AJP. Hence the wordpress.conf file in /etc/apache2/sites-enabled has:
JkMount / ajp13
JkMount /* ajp13
JkUnMount /blog* ajp13
This means that the default context (/) and everything below it is given to the mod_jk plugin to send to Tomcat. The JkUnMount means that /blog is left for Apache to deal with.
In /var/lib/tomcat6/conf/server.xml the Connector element for port 80 is commented out and the Connector element for AJP/1.3 on port 8009 is commented in. I left the Connector for 443 (HTTPS) in for Tomcat because I decided that I didn’t want to deal with the details of connecting SSL through Apache to Tomcat and I don’t yet need it.
You will also need to setup the /etc/apache2/mods-available/jk.conf to configure mod_jk. Rajeev Sharma’s instructions work perfectly. Lastly, you will need symlinks in /etc/apache2/mods-enabled to both jk.conf and jk.load.
I used the WordPress instructions for creating a network so that I could have two blogs. The way to do this is to setup the root blog at /blog following the normal instructions. You then create the network blogs (/blog/site and /blog/technical in this case). The problem is that you now have a blog at /blog that you may not want. To fix that I added the following rules to /etc/apache2/sites-available/wordpress.conf to redirect traffic for /blog and /blog/ to /blog/site.
RewriteRule /blog/$ /blog/site [R=301]
RewriteRule /blog$ /blog/site [R=301]
I wanted to use the Google FeedBurner service to track the blog subscribers and all the other useful things that service provides. I burnt the feeds for my blogs at Feedburner and then used the MyBrands service so that the resulting links are feeds.trailhunger.com/TrailHungerSiteBlog and so on. The FeedBurner FeedSmith plugin works great to change all your public links to point to the new feeds. For a network install you have to Network Activate it and then go to each blog to activate it there.
Lastly, I used ThemesPress to create a theme from my existing HTML (hat tip to Patrick McKenzie for that). That’s why the header on the blog matches the hedear on the main site (except for Cufon not getting the fonts right, grrr)