如何在端口80上的nginx上启动rails app

时间:2012-04-07 12:52:11

标签: ruby-on-rails nginx passenger production

我无法在端口80上启动我的站点,但只能在3000上启动.Nginx显示标准索引页面。 Nginx配置:

http {
  passenger_root /home/my_user_name/.rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11;
  passenger_ruby /home/my_user_name/.rvm/wrappers/ruby-1.9.3-p125/ruby;

  include       mime.types;
  default_type  application/octet-stream;

  keepalive_timeout 65;

  server {
    listen 80;
    server_name www.my_site_name.com
    root /home/my_user_name/my_site_name/public;   # <--- be sure to point to 'public'!
    passenger_enabled on;
  }

}

命令:

passenger start -e production  # successfully started on port 3000

rvmsudo passenger start -e production -p 80 # error, see below

错误:

*** ERROR ***
The address 0.0.0.0:80 is already in use by another process, perhaps another
Phusion Passenger Standalone instance.

If you want to run this Phusion Passenger Standalone instance on another port,
use the -p option, like this:

  passenger start -p 81

感谢您的帮助!

3 个答案:

答案 0 :(得分:1)

Nginx正在侦听端口80.Presenger Standalone是在没有Web服务器的情况下使用的。在运行Nginx的情况下,您不能单独启动Passenger。

Docs for Passenger with Nginx

Docs for Passenger Standalone

答案 1 :(得分:1)

我认为您需要在端口80上为您的服务器指定location,如下所示:

http {
  # ...

  server {
    listen 80;
    server_name www.my_site_name.com

    location / {
      root /home/my_user_name/my_site_name/public;
      passenger_enabled on;
    }
  }
}

正如jdl指出的那样,您也不需要运行Passenger Standalone。您不需要这些命令。 Nginx将为您服务。

答案 2 :(得分:1)

好的,你的初始配置是正确的......所以运行这个命令来启动rails app:

rvmsudo passenger start -e production -p 80 --user="TYPE HERE USERNAME FROM SSH"