1

一直在与 Nginx 和乘客合作。我已成功让一个应用程序/域正常工作。但是对于我的服务器,我有 2 个以上的域,我计划从 nginx 到它们各自的根目录,每个 Rails 应用程序都将在该根目录中运行。

我尝试了许多技术,但没有一个奏效。所有域都采用第一个根设置,而不是它们应该是的根。

这是我的 nginx.conf 文件:

  server { 
    listen 80;
    server_name www.danielcw.info;
    root /root/public/danielcw.info/public;   # <--- be sure to point to 'public'!
    access_log  /root/public/danielcw.info/log/access.log;
    error_log /root/public/danielcw.info/log/error.log;
    passenger_enabled on;
    rails_env development;
  } 

  server {
    listen 80;
    server_name www.ericoppi.com;
    root /root/public/ericcoppi.com/public;   # <--- be sure to point to 'public'!
    access_log  /root/public/ericcoppi.com/log/access.log;
    error_log /root/public/ericcoppi.com/log/error.log;
    passenger_enabled on;
    rails_env development;
  }

任何帮助深表感谢!

4

1 回答 1

1

该配置应该可以正常工作 - 我要做的唯一更改是通过 nginx 提供 www 和 no-www 服务:

  server { 
    listen 80;
    server_name danielcw.info www.danielcw.info;
    root /root/public/danielcw.info/public;
    access_log  /root/public/danielcw.info/log/access.log;
    error_log /root/public/danielcw.info/log/error.log;
    passenger_enabled on;
    rails_env development;
  } 

  server {
    listen 80;
    server_name ericoppi.com www.ericoppi.com;
    root /root/public/ericcoppi.com/public;
    access_log  /root/public/ericcoppi.com/log/access.log;
    error_log /root/public/ericcoppi.com/log/error.log;
    passenger_enabled on;
    rails_env development;
  }

确保在编辑配置文件后重新启动了 nginx。

于 2012-08-16T22:52:40.877 回答