无法为 rails 应用程序部署配置 passenger 和 nginx

Unable to configure passenger and nginx for rails app deployment

我正在使用 CentOS 在 VPS 上部署一个 rails 应用程序。我用 gem install passenger 安装了 passenger。为了安装 nginx,我使用了 rvmsudo passenger-install-nginx-module.

在我设置的nginx配置文件中:

server { 
        listen       80; 
        server_name  my-ip-address;  

       location / { 
            root   /home/deploy/repos/application-name/public; 
            passenger_enabled on; 
            rails_env production;  
        }
        ...
}

当我执行 sudo service nginx status 时,我得到以下信息:

nginx (pid 21015 21014) is running...

这表明 nginx 是 运行ning.

但我在浏览器上收到 This webpage is not available

即使我在 rails s 的开发模式下打开 rails 服务器并尝试使用 my-ip-address:3000

签入浏览器时也得到相同的结果

任何人都可以帮助解决可能的问题吗?

当我运行命令passenger-config restart-app时,结果是:

Phusion Passenger is currently not serving any applications

我需要关于这是 nginx 问题还是 passenger 问题的建议?

还有一个问题是-

如果我的 passenger 安装不正确但 nginx 安装正确,那么我能看到 "welcome to nginx page" 吗?

更新:

我试过运行宁passenger start -p 3000 -d -e production乘客在后台服务。现在,如果我这样做 passenger-status,我会得到两个 passenger 实例,其中一个显示 Phusion Passenger is currently not serving any applications,另一个显示如下:

Version : 5.0.21
Date    : 2016-01-16 10:42:42 +0530
Instance: feOajf7V (nginx/1.8.0 Phusion_Passenger/5.0.21)

----------- General information -----------
Max pool size : 6
App groups    : 1
Processes     : 1
Requests in top-level queue : 0

----------- Application groups -----------
/home/deploy/repos/application-name/public (production):
  App root: /home/deploy/repos/application-name
  Requests in queue: 0
  * PID: 22003   Sessions: 0       Processed: 0       Uptime: 4m 17s
    CPU: 0%      Memory  : 36M     Last used: 4m 17s ago

如果我 运行 passenger-config restart-app 我得到的结果是:

Please select the application to restart.
 ‣   /home/deploy/repos/application-name/public (production)
     Cancel

这是否意味着 passenger 工作正常?但是我在浏览器中看到 webpage not available

我不是大师,但在我的(工作 ;) ) 安装中我有:

keepalive_timeout 10;
passenger_enabled on;
root /var/www/org/current/public;

服务器块中,而不是位置块。希望对你有帮助。

快速浏览文档告诉我同样的事情: https://www.phusionpassenger.com/library/deploy/nginx/deploy/ruby/

我不知道这是否会为您解决问题,因为我记得让 nginx 和 passenger 工作有点繁琐,我使用 Chef,但这应该有所帮助。

我认为您的项目目录中没有 运行 passenger。 在你的项目类型的 root 目录中:

passenger start -p <port>

其中 <port> 是您想要 运行 您的应用程序(例如:8000)的端口。

更新

根据你问题的更新和下面的评论,问题似乎不在nginx或passenger的配置上。由于您尝试访问您的服务器不是在本地而是使用 VPS 的真实 IP,因此有可能相关端口未打开。你可以检查一下 here.