【问题标题】:Unable to configure passenger and nginx for rails app deployment无法为 Rails 应用程序部署配置乘客和 nginx
【发布时间】:2016-04-20 21:01:00
【问题描述】:

我正在使用 CentOS 在 VPS 上部署一个 rails 应用程序。我已经用gem install 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 正在运行。

但我在浏览器上收到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 还是乘客的问题的建议?

还有一个问题是-

如果我的乘客没有正确安装但 nginx 安装正确,那么我能看到“欢迎使用 nginx 页面”吗?

更新:

我尝试运行passenger start -p 3000 -d -e production,由该乘客在后台提供服务。现在,如果我这样做passenger-status,我会得到两个乘客实例,其中一个说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

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

【问题讨论】:

  • 把这篇文章通读一遍,你就会掌握它的窍门:digitalocean.com/community/tutorials/…
  • 对不起,我没有在问题中提到,但我已经按照同一篇文章安装 nginx 和乘客,并且还包含了 nginx 管理脚本。

标签: ruby-on-rails ruby ruby-on-rails-4 nginx passenger


【解决方案1】:

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

passenger start -p <port>

&lt;port&gt; 是您希望运行应用的端口(例如:8000)。

更新

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

【讨论】:

  • 我已按照您的建议使用我得到的结果更新了我的问题。还是行不通。会是 nginx 的问题吗?
  • 抱歉这么晚才回复您,请问您在浏览器的地址栏中输入了什么?
  • 我只是在浏览器中输入IPAddress。
  • 好的,我知道问题出在哪里了。您必须输入 IP 和端口,即 127.0.0.1:3000 或只是 localhost:3000
  • 感谢您的回复,但是当我开始独立乘客时,我尝试使用您提到的端口,但使用 nginx,我只尝试我的 IPAddress。我在前面的问题中提到过Even I get the same result when I put on the rails server in the development mode with rails s and try to check in the browser with my-ip-address:3000
【解决方案2】:

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

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

在服务器块,而不是位置块。希望对您有所帮助。

对文档的快速搜索告诉我同样的情况: https://www.phusionpassenger.com/library/deploy/nginx/deploy/ruby/

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

【讨论】:

  • 感谢您的快速响应。我也试过了,但得到了同样的“网页不可用”。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多