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 -vin site root returns 1.9.3), RVM, Ruby Gems, Rails (rails -vin app folder returns 3.2.8 and I can start arails serverin 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.comthat 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 installin/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!
If you’re working with apache2.2, you should not include the following in apache2.conf
Instead you should create 2 files on
/etc/apache2/mods-available:passenger.load with:
passenger.conf with:
Finally you just run:
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.