简体   繁体   中英

Why is my Rails app not loading using Passenger 3, RVM and Rails 3.1?

I am having difficulties with Passenger 3, Apache, RVM and a Rails 3.1 application on Ubuntu. For some reason, the Rails app is not loading, however I have run basically the same configuration before and had no problem.

I have Ruby 1.9.2 installed in RVM and Passenger installed with all gems in default.

I put the following in the apache.conf file:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.2-p290/ruby

This is my virtual hosts configuration:

<VirtualHost *:80>
  ServerName server
  DocumentRoot /root/www/tester/public
  <Directory /root/www/tester/public>
    Allow from all
    Options -MultiViews
  </Directory>
</VirtualHost>

Passenger appears to be loading, as the Apache log shows:

[Wed Jan 11 23:18:28 2012] [notice] Apache/2.2.20 (Ubuntu) Phusion_Passenger/3.0.11 configured -- resuming normal operations

but, I cannot get the application to load at all.

If I run Passenger standalone I get the following error:

2012/01/11 23:03:31 [error] 13427#0: *4 "/root/www/sound/public/index.html" is forbidden (13: Permission denied), client: 127.0.0.1, server: _, request: "HEAD / HTTP/1.1", host: "0.0.0.0"

I changed all the permissions to 755 and gave ownership to apache (www-data) but to no avail.

Finally, when I run passenger-status, I get:

----------- General information -----------
  max      = 6
  count    = 0
  active   = 0
  inactive = 0
 Waiting on global queue: 0

----------- Application groups -----------

But, as you can see, there is no application loaded.

FIXED! - I needed to delete the default virtual hosts file in sites-enabled directory!

My guess is you're looking in the right place, and its something to do with user permissions.

Number 1 rule for Passenger is;

  • Passenger will run as the user which owns "config/environment.rb" (or "config.ru" for rack apps)

Also, I'd suggest, don't ever run as root.

/var/www or /var/rails are common places to put your rails apps

but I usually end up having a user for each app, and putting it in the home directory.

Namely, for my application I have;

  1. the user myapp
  2. the directory /home/myapp/deploy/
  3. a symlink to the code at /home/myapp/deploy/current
  4. all these directories are owned by myapp

My apache config is something like

<VirtualHost *:80>
  ServerName myapp.com
  DocumentRoot /home/myapp/deploy/current
</VirtualHost>

For me this makes the separation of ownership clear, and avoids any of these problems.

(notably, all tasks done via capistrano are done as the myapp user)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM