简体   繁体   English

在已经安装 Nginx 的情况下安装Passenger; 可能的?

[英]Installing Passenger when Nginx is already installed; Possible?

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;
}

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 attached to nginx.您描述的所有乘客相关指令(passenger_root、passenger_ruby、passenger_enabled)仅在乘客模块附加到 nginx 时可用。 This is why you have to compile nginx with --add-module='/path/to/passenger-3.0.9/ext/nginx' .这就是为什么您必须使用--add-module='/path/to/passenger-3.0.9/ext/nginx'编译 nginx。

Unfortunately, I don't know of any method to enable passenger module without re-installing nginx.不幸的是,我不知道有什么方法可以在不重新安装 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.但是,根据http://wiki.nginx.org/Modules ,“必须在编译时选择 Nginx 模块。”,所以可能没有办法做到这一点。

In Passenger docs the chapter "Generic installation, upgrade and downgrade method: via RubyGems" discusses this.在Passenger 文档中, “通用安装、升级和降级方法:通过RubyGems”一章对此进行了讨论。 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 gem,就需要重新编译nginx(然后使用yum/apt-get-installed nginx,如果存在的话)。 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.乘客的编译/配置实用程序“passenger-install-nginx-module”为您完成(它是Passenger gem的一部分),它会自动包含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).它还使您可以选择添加自己的开关(例如用于额外模块,或启用/禁用 NGiNX 的内置功能)。

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

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.在开始之前,您应该知道在其 Nginx 集成模式下安装Passenger 涉及使用Passenger 的代码扩展Nginx。 However, Nginx does not support loadable modules.但是,Nginx 不支持可加载模块。 This means that in order to install Passenger's Nginx integration mode, it is necessary to recompile Nginx from source.这意味着为了安装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 实例,则解决方案就在这里

There is a way install nginx passenger module without reinstalling/recompiling nginx有一种无需重新安装/重新编译 nginx 即可安装 nginx 乘客模块的方法

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM