Config Notes: Rails App Setup in an Apache Virtual Directory

If you’re starting your Ruby on Rails adventure and learning the ropes you’ll probably want to be able to quickly create new Rails applications in virtual directories on a single apache development site. 

http://devsite/app1
http://devsite/app2
etc…

If so you may encounter configuration issues that you didn’t see when getting your first Rails demo site up and running.  Here we’ll touch on a few gotchas you might encounter and how to quickly resolve them.

Let’s start by creating the Rails application by going into the directory above where the app will reside and

$ rails new app1

Then we’ll follow the Phusion Passenger documentation on deploying to a sub URI for Apache.

We want to make sure Passenger is enabled for our Rails application.  We’ll know we’re onboard when we click on "About Your Application’s Environment" link and see what we’re supposed to see as opposed to a "/rails/info/properties Not Found" message.  We covered the properties not found issue in an earlier post.

One additional point to remember when configuring Rails in a virtual directory is to set AllowOverride to "all" in the site root in your Site-Available config file.

Application Could Not Be Started

If you encounter an "Application could not be started" error when launching the Rails application, it’s a good bet that either Node.js or Execjs are not installed, or both.  Here’s a guide on installing Node.js from David King, and for installing Execjs, a simple

$ sudo gem install execjs

will do the trick.