Linux 在已经安装 Nginx 的情况下安装Passenger;可能的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7612787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing Passenger when Nginx is already installed; Possible?
提问by
Rather a simple question I believe, is it possible to install passenger when nginx is already installed on your webserver?
我相信这是一个简单的问题,当您的网络服务器上已经安装了 nginx 时,是否可以安装乘客?
If the answer is Yes, I already performed these actions:
如果答案是肯定的,我已经执行了这些操作:
At this very moment I already have nginx installed (for my PHP applications) and next I did a checkout of the passenger's git repository:
此时我已经安装了 nginx(用于我的 PHP 应用程序),接下来我检查了乘客的 git 存储库:
mkdir /repositories
cd /repositories/
git clone https://github.com/FooBarWidget/passenger.git
cd passenger/
and then add this snippet to /etc/nginx/conf/nginx.conf
然后将此代码段添加到 /etc/nginx/conf/nginx.conf
http {
...
passenger_root /repositories/passenger;
passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p290/ruby;
...
}
However when I want to restart nginx I get the following error:
但是,当我想重新启动 nginx 时,出现以下错误:
* Starting Web Server nginx
nginx: [emerg] unknown directive "passenger_root" in /etc/nginx/nginx.conf:19
Which concludes me to say that there is still some config I need to set, for nginx to be aware that we're using passenger.
最后我要说的是,我仍然需要设置一些配置,以便 nginx 知道我们正在使用乘客。
My server block
我的服务器块
server {
listen 80;
server_name rails.kreatude.com;
root /srv/www/my_test_app;
passenger_enabled on;
}
采纳答案by Ion Br.
I think your problem is that the passenger module is not present in nginx.
我认为您的问题是 nginx 中不存在乘客模块。
All the passenger dependent directives you've described (passenger_root, passenger_ruby, passenger_enabled) are available only when the passenger module is attachedto nginx. This is why you have to compile nginx with --add-module='/path/to/passenger-3.0.9/ext/nginx'
.
您描述的所有乘客相关指令(passenger_root、passenger_ruby、passenger_enabled)仅在乘客模块附加到 nginx时可用。这就是为什么你必须用--add-module='/path/to/passenger-3.0.9/ext/nginx'
.
Unfortunately, I don't know of any method to enable passenger module without re-installing nginx. But, according to http://wiki.nginx.org/Modules, "Nginx modules must be selected at compile-time.", so there could be a chance that there isn't a way to do that.
不幸的是,我不知道有什么方法可以在不重新安装 nginx 的情况下启用乘客模块。但是,根据http://wiki.nginx.org/Modules,“必须在编译时选择 Nginx 模块。”,所以可能没有办法做到这一点。
回答by James
passenger_enabled on;
in server, http, or location block.
passenger_enabled on;
在服务器、http 或位置块中。
http://modrails.com/documentation/Users%20guide%20Nginx.html#_important_deployment_options
http://modrails.com/documentation/Users%20guide%20Nginx.html#_important_deployment_options
回答by Ville
In Passenger docs the chapter "Generic installation, upgrade and downgrade method: via RubyGems"discusses this. Basically, once the Passenger gem is installed, nginx needs to be recompiled (and then used instead of the yum/apt-get-installed nginx if one exists). Passenger's compilation/configuration utility "passenger-install-nginx-module" does it for you (it's part of the Passenger gem), and it automatically includes the necessary switches for Passenger. It also gives you the option to add your own switches (such as for extra modules, or to enable/disable NGiNX's built-in features).
在Passenger 文档中,“通用安装、升级和降级方法:通过RubyGems”一章对此进行了讨论。基本上,一旦安装了Passenger gem,就需要重新编译nginx(然后使用yum/apt-get-installed nginx,如果存在的话)。乘客的编译/配置实用程序“passenger-install-nginx-module”为您完成(它是Passenger gem的一部分),它会自动包含Passenger所需的开关。它还使您可以选择添加自己的开关(例如用于额外模块,或启用/禁用 NGiNX 的内置功能)。
回答by Allen
With rvm, you could do this simply by running rvmsudo passenger-install-nginx-module
.
使用rvm,您只需运行rvmsudo passenger-install-nginx-module
.
For more detail: https://www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu.
有关更多详细信息:https: //www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu。
回答by HichameMoriceau
I confirm ion-br's answer, I'm facing the same kind of problems and PhusionPassenger's site states:
我确认 ion-br 的回答,我面临同样的问题,PhusionPassenger 的网站指出:
Before you begin, you should know that installing Passenger in its Nginx integration mode involves extending Nginx with code from Passenger. However, Nginx does not support loadable modules. This means that in order to install Passenger's Nginx integration mode, it is necessary to recompile Nginx from source.
在开始之前,您应该知道在其 Nginx 集成模式下安装Passenger 涉及使用Passenger 的代码扩展Nginx。但是,Nginx 不支持可加载模块。这意味着为了安装Passenger的Nginx集成模式,需要从源码重新编译Nginx。
The only solution is thus to properly reinstall Nginx, if your machine is an AWS AMI instance the solution lies here.
因此,唯一的解决方案是正确重新安装 Nginx,如果您的机器是 AWS AMI 实例,则解决方案就在这里。
回答by Yu Jiaao
There is a way install nginx passenger module without reinstalling/recompiling nginx
有一种无需重新安装/重新编译 nginx 即可安装 nginx 乘客模块的方法