Ruby/Rails Apache2 & Passenger setup returning directory listing

passenger, ruby-on-rails, ubuntu-12.04, vps

Solution

If you're working with apache2.2, you should not include the following in apache2.conf

LoadModule passenger_module /var/lib/gems/1.8/gems/passenger 3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.17
PassengerRuby /usr/bin/ruby1.8

Instead you should create 2 files on `/etc/apache2/mods-available`:

passenger.load with:

LoadModule passenger_module /var/lib/gems/1.8/gems/passenger3.0.17/ext/apache2/mod_passenger.so

passenger.conf with:

PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.17
PassengerRuby /usr/bin/ruby1.8

Finally you just run:

a2enmod passenger

And it's done. By the way, when you make it work you might consider using a more recent version of ruby (1.9.3... or so). The best way to do that is using RVM.

Problem

It's worth nothing, first of all, that I've got a fully-functional Apache2 server (on a Ubuntu 12.04 VPS) with multiple working virtual hosts (but this is my first attempt to deploy a Rails site). Additionally, the Rails site I'm trying to launch is fully functional on my local WEBRick server. I've referenced various online instructions for making Apache, Ruby, Rails & Passenger play nice together, including: - This from Linode, my host (they don't offer documentation specific for 12.04) - This from O'Reilly - The Passenger documentation that's part of the installation process of `passenger-install-apache2-module` - The online Passenger documentation - Various old SO questions such as this and this To summarize, so far I've: - Installed Ruby (`ruby -v` in site root returns 1.9.3), RVM, Ruby Gems, Rails (`rails -v` in app folder returns 3.2.8 and I can start a `rails server` in the app folder) & Passenger (including all dependencies) As instructed by `passenger-install-apache2-module`, I've added the following lines to the bottom of `/etc/apache2/apache2.conf`: ``` LoadModule passenger_module /var/lib/gems/1.8/gems/passenger 3.0.17/ext/apache2/mod_passenger.so PassengerRoot /var/lib/gems/1.8/gems/passenger-3.0.17 PassengerRuby /usr/bin/ruby1.8 ``` Created & enabled (it's listed in `/etc/apache2/sites-enabled/`) a virtual host `/etc/apache2/sites-available/foo.com` that contains the following: ``` <VirtualHost *:80> ServerName foo.com DocumentRoot /home/user/public/foo.com/public <Directory /home/user/public/foo.com/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost> ``` Uploaded my Rails app to `/home/user/public/foo.com/` Did a `bundle install` in `/home/user/public/foo.com/` On my local OSX machine, I've add `xxx.xxx.xxx.xxx foo.com` [the VPS IP] to `/etc/hosts`. Restarted Apache But when I navigate to foo.com in the browser, I simply see a listing of `/home/user/public/foo.com/public`. Also, there are no recent entries in the Apache `error.log`. However, whenever I `restart` Apache I get: ``` * Restarting web server apache2 [Fri Oct 26 00:04:12 2012] [warn] module passenger_module is already loaded, skipping ... waiting [Fri Oct 26 00:04:13 2012] [warn] module passenger_module is already loaded, skipping ...done. ``` I'm hoping I've overlooked something really stupid. Any help figure out what that is would be much, much appreciated. Thanks!

Original source

Related problems