安装Nginx时安装Passenger;可能?

时间:2011-09-30 15:37:35

标签: ruby-on-rails linux ubuntu nginx passenger

我相信这是一个简单的问题,是否可以在您的网络服务器上安装nginx时安装乘客?

如果答案是肯定的,我已经执行了以下操作:

此时我已经安装了nginx(对于我的PHP应用程序),接下来我检查了乘客的git存储库:

mkdir /repositories
cd /repositories/
git clone https://github.com/FooBarWidget/passenger.git
cd passenger/

然后将此代码段添加到/etc/nginx/conf/nginx.conf

  http {
      ...
      passenger_root /repositories/passenger;
      passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p290/ruby;
      ...
  }

但是当我想重新启动nginx时,我收到以下错误:

* Starting Web Server nginx
nginx: [emerg] unknown directive "passenger_root" in /etc/nginx/nginx.conf:19

我最后说我还需要设置一些配置,让nginx知道我们正在使用乘客。

我的服务器块

server {
  listen 80;
  server_name rails.kreatude.com;
  root /srv/www/my_test_app;
  passenger_enabled on;
}

6 个答案:

答案 0 :(得分:16)

我认为您的问题是乘客模块不在nginx中。

您所描述的所有乘客相关指令(passenger_root,passenger_ruby,passenger_enabled)仅在乘客模块连接到nginx时可用。这就是你必须用--add-module='/path/to/passenger-3.0.9/ext/nginx'编译nginx的原因。

不幸的是,我不知道在没有重新安装nginx的情况下启用乘客模块的任何方法。但是,根据http://wiki.nginx.org/Modules,“必须在编译时选择Nginx模块。”,因此可能无法做到这一点。

答案 1 :(得分:2)

在Passenger docs中,"Generic installation, upgrade and downgrade method: via RubyGems"章讨论了这一点。基本上,一旦安装了Passenger gem,就需要重新编译nginx(然后使用它而不是yum / apt-get-installed nginx,如果存在的话)。 Passenger的编译/配置实用程序“passenger-install-nginx-module”为您完成(它是Passenger gem的一部分),它自动包含Passenger所需的开关。它还为您提供了添加自己的开关的选项(例如,用于额外的模块,或启用/禁用NGiNX的内置功能)。

答案 2 :(得分:0)

使用rvm,您只需运行rvmsudo passenger-install-nginx-module即可完成此操作。

更多详情:https://www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu

答案 3 :(得分:0)

我确认了离子的回答,我遇到了同样的问题,PhusionPassenger的网站声明:

  

在开始之前,您应该知道在其Nginx集成模式下安装Passenger涉及使用Passenger中的代码扩展Nginx。但是,Nginx不支持可加载模块。这意味着为了安装Passenger的Nginx集成模式,有必要从源代码重新编译Nginx。

唯一的解决方案是正确地重新安装Nginx,如果您的计算机是AWS AMI实例,则解决方案是here

答案 4 :(得分:0)

有一种方法可以安装nginx乘客模块,而无需重新安装/重新编译nginx

https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/bionic/install_passenger.html

答案 5 :(得分:-2)

服务器,http或位置块中的

passenger_enabled on;

http://modrails.com/documentation/Users%20guide%20Nginx.html#_important_deployment_options

相关问题