Deploying a Rails app (into a subdirectory)

Some notes on deploying my rails application in to a subdirectory. I’m using rvm to manage Rails versions and this was all on Debian Lenny.

1. Install Rails (see here for some pointers).

2. Install Passenger

gem install passenger
apt-get install apache2-prefork-dev
apt-get install libapr1-dev
apt-get install libaprutil1-dev

Follow the instructions passenger gives you.

3. Edit your apache config

3.1 Create a symlink to your app’s public directory inside your current website root:

(in this example my app is call nihongo)

ln -s /PATH/TO/WEBAPP/nihongo/public /PATH/TO/YOUR/DOCROOT/nihongo

3.1 Edit your apache config for this root to contain a pointer to this app:

RackBaseURI /nihongo
<Directory /PATH/TO/YOUR/DOCROOT/nihongo>
Options -MultiViews

4. Checkout your app…

Possibly use rake db:setup to setup the database. Use “bundle install” to install required bundle files.


rake assets:precompile

to “compile” assets, or you may get an error such as:

Completed 500 Internal Server Error in 518ms

ActionView::Template::Error (application.css isn't precompiled):
    2: <html>
    3: <head>
    4:   <title>Nihongo</title>
    5:   <%= stylesheet_link_tag    "application" %>
    6:   <%= javascript_include_tag "application" %>
    7:   <%= csrf_meta_tags %>
    8: </head>
  app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___2940450108335557336_39013520'
  app/controllers/words_controller.rb:8:in `index'

I don’t quite understand how Rails detects the app is running in production yet. But it does so automatically somehow…