I have a RoR web app that I’m trying to serve up with Passenger on Apache. The weird thing is that I can access the web app if I use Passenger Standalone, but I can’t seem to access the web app using Apache with the Passenger module.
The passenger module appears to be running as evidenced by the fact that I can start Apache with no errors and that Passenger-status returns the following:
----------- General information -----------
max = 6
count = 0
active = 0
inactive = 0
Waiting on global queue: 0
----------- Application groups -----------
When I try to access the web app I get a listing of the public folder directory.
Here is my virtual hosts file:
<VirtualHost *:80>
ServerAdmin smith@example.com
DocumentRoot /home/smith/www/dashboard/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/smith/www/dashboard/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have the following at the end of my apache2.conf file:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger 3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11
PassengerRuby /usr/bin/ruby1.8
I am pulling my hair out trying to figure this out. Would appreciate some help with this.
Thanks.
After weeks of trial and error I have finally been able to fix this by RTFM. I am surprised that there were no responses to my question on Stackoverflow and I was not able to find any other articles elsewhere that helped with my question. This issue has to be affecting everyone who is deploying a RoR app using Capistrano on a Linux server running Apache2 and Passenger.
I have Capistrano deploying the app to /home/smith/www/dashboard which creates a current folder which symlinks to releases/
Passenger needs to find config/environment.rb to launch the Rails app. By default, Phusion Passenger assumes that the application’s root directory is the parent directory of the public directory.See: http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerAppRoot
The problem is that when using Capistrano, by default it deploys the app to
/home/smith/www/dashboard/current/
So by default Passenger reckons the path to be:
/home/smith/www/dashboard/config/environment.rb
Passenger provides the ability to set the PassengerAppRoot configuration option in Apache virtual host file like so:
PassengerAppRoot /home/smith/www/dashboard/current
This allows Passenger to find the config/environment.rb file correctly:
PassengerAppRoot /home/scervera/www/dashboard/current/config/environment.rb
Here is the rest of my virtual host file:
There may be other ways to fix this, but I believe this is “by the book”.