Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I'm going to use my own blog which is a Wordpress installation and serve a Rails application from the subdirectory "reader". Note, I'm not going to keep my Rails application in the document root of my Wordpress Blog, which is a PHP application and therefore anyone could browse the ruby source code :(. I'll keep it elsewhere on the filesystem and tell Apache about the location in the VirtualHost file.
You can visit the application by going to http://seanbehan.com/reader. The application just parses a bunch of RSS feeds and displays them. It uses the Feedzirra library, which I've also written about http://seanbehan.com/ruby-on-rails/installing-feedzirra-rss-parser-on-ubuntu-8/.
I'm using Phussion Passenger and Ruby Enterprise Edition from the folks at Mod Rails. Installing both Phussion Passenger and Ruby Enterprise Edition is simple and a very well documented process. However, you'll need to download and compile them from source. If you install Ruby Enterprise Edition (REE) it comes w/ Passenger so you won't need to download it separately. I recommend going with REE. http://www.rubyenterpriseedition.com/download.html
wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz tar xzvf ruby-enterprise-X.X.X.tar.gz ./ruby-enterprise-X.X.X/installerWhen you run the installer you'll be prompted for an installation location. Just hit enter to install in the default location. Follow the instructions from there and remember to copy/paste any code that they give you.
Official Instructions on installation for Passenger on its own are available here http://www.modrails.com/install.html I've written about setting up an entire box w/ Passenger here http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rails-git-and/ If you already have Passenger installed and want to use REE just download and install REE and it'll recompile Passenger with REE support if you follow the instructions.
*** If you install REE you'll need to either link or reinstall all your gems. I linked the REE gem with the one in /usr/bin so that I can run gem install
ln -s /opt/ruby-enterprise-X.X.X/bin/gem /usr/bin/gem
<VirtualHost *> # Normal virtual host info ServerName seanbehan.com ServerAlias *.seanbehan.com DocumentRoot /var/www/seanbehan.com/wordpressThe "Location" directive tells apache to forward requests starting with /reader to the directory /var/www/seanbehan.com/reader/public which is the location of our Rails app. However, we need to add the PassengerAppRoot assignment so that it knows where the actual application lives.
Rails info goes here
Alias /reader /var/www/seanbehan.com/reader/public <Location /reader> PassengerAppRoot /var/www/seanbehan.com/reader RailsEnv production </Location> </VirtualHost>
map.resources :feeds, :path_prefix => "reader"
This will work but you can add a line to your RAILS_ROOT/config/environments/production.rb file which will handle all your routes for you. This way you don't need to setup a relative path on your development environment work.
# in RAILS_ROOT/config/environments/production.rb config.action_controller.relative_url_root = '/reader'
Also I've read some people have trouble using the alias with passenger. This may be an older issue but works for me without a problem on Ubuntu (latest).
Here are some useful resources I found along the way... http://robots.thoughtbot.com/post/159806388/phusion-passenger-with-a-prefix http://www.modrails.com/documentation/Users%20guide.html#deploying_rails_to_sub_uri http://www.modrails.com/documentation/Users%20guide.html#RailsBaseURI http://stackoverflow.com/questions/848258/server-prefix-and-rails-routes
Just finishing up brewing up some fresh ground comments...