Deploying Wordpress with Rails on Passenger

Posted: 05/20/2009

I just finished integrating a Wordpress blog into a soon-to-be released Rails app, and I would like to share the steps I took to get it deployed on Phusion Passenger. Getting the permalinks working correctly had me hung up for a bit, so I’ll show you how to get around that.

To get started we can drop the blog right into the public directory of our rails app:

  cd /yourapp/public
  wget http://wordpress.org/latest.tar.gz
  tar xzvf latest.tar.gz
  mv wordpress blog     <--- blog will be at http://yourapp/blog
  cd blog
  mv wp-config-sample.php wp-config.php

Now edit the wp-config.php file (instructions are in the file) and be sure to grant database privileges to the user you specify.

Next, you have to edit your apache config file to disable passenger for the blog directory:

<VirtualHost ...>
    ServerName ...
    DocumentRoot ...
    <Location /blog>
       PassengerEnabled off
    </Location>
</VirtualHost>

I found that snippet here.

Restart Apache and point your browser to http://yourapp/blog/index.php to setup the rest of your blog through Wordpress’s web interface. One thing you will probably edit is the default permalink structure (Found at settings > permalink). I prefer to set a custom structure of ‘/%postname%’. Regardless of the structure you use, wordpress will tell you to edit the .htaccess file in your blog directory. For the life of me I could not get .htaccess file to be recognized, so as a workaround I copied the snippet that wordpress specified into my apache config as follows:

<VirtualHost ...>
    ServerName ...
    DocumentRoot ...
    <Location /blog>
       PassengerEnabled off
       <IfModule mod_rewrite.c>
         RewriteEngine On
         RewriteBase /blog/
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteCond %{REQUEST_FILENAME} !-d
         RewriteRule . /blog/index.php [L]
       </IfModule>
    </Location>
</VirtualHost>

Finally, restart Apache.

About Me

I'm a skier, web developer, entrepreneur, freelancer, and all around stand-up guy living in Manhattan. This is me, repping one of my favorite shirts...

Follow me on twitter or send me an email.

All Posts