简体   繁体   English

安装 Phusion Passenger 作为动态 Nginx 模块; 模块似乎没有加载但没有错误

[英]Installing Phusion Passenger as a dynamic Nginx module; module doesn't seem to load but no errors

I'm trying to install Phusion Passenger as a dynamic module with Nginx installed from the repo.我正在尝试将 Phusion Passenger 安装为动态模块,其中 Nginx 从 repo 安装。 The process seems to be working but my Meteor app doesn't load and it looks like the Passenger module isn't running.该过程似乎正在运行,但我的 Meteor 应用程序未加载,并且似乎乘客模块未运行。

OS: RedHat 8操作系统:红帽 8

Nginx: 1.20.1 Nginx:1.20.1

Passenger: Standalone 6.0.12乘客:独立 6.0.12

Meteor: 2.5.1 Meteor:2.5.1

How I've built the module:我是如何构建模块的:

  1. Install Passenger standalone as per the tutorial按照教程独立安装Passenger

  2. Install passenger-devel 安装乘客开发

sudo dnf install passenger-devel.x86_64
  1. Check installation检查安装
sudo /usr/bin/passenger-config validate-install

This shows "Everything looks good"这显示“一切看起来都不错”

  1. Check the Passenger module path检查乘客模块路径
passenger-config --nginx-addon-dir

returns返回

/usr/share/passenger/ngx_http_passenger_module

and

sudo ls /usr/share/passenger/ngx_http_passenger_module

shows节目

config       ContentHandler.c  ngx_http_passenger_module.c  StaticContentHandler.h
ConfigGeneral    ContentHandler.h  ngx_http_passenger_module.h
Configuration.c  LocationConfig    README.md
Configuration.h  MainConfig    StaticContentHandler.c
  1. Install PCRE安装 PCRE
sudo yum install pcre-devel
  1. Install Nginx from repo从 repo 安装 Nginx
sudo yum module list nginx
sudo yum module reset nginx
sudo yum module enable nginx:1.20
sudo yum install nginx
sudo systemctl enable nginx
  1. Download Nginx source code下载Nginx源代码
wget https://nginx.org/download/nginx-1.20.1.tar.gz
tar zxf nginx-1.20.1.tar.gz
cd nginx-1.20.1/
  1. Check compile flags:检查编译标志:
nginx -V
  1. Used the output of nginx -V to construct and then run the configure command (though as the output showed --wtih-compat I could probably have used ./configure --with-compat --add-dynamic-module=$(passenger-config --nginx-addon-dir) instead)使用nginx -V的 output 构建然后运行configure命令(尽管 Z78E6221F6393D1356681DB398$F14CE6DZ 显示 --wtih-config ./configure --with-compat --add-dynamic-module=$(passenger-config --nginx-addon-dir)我可能已经使用了。 ./configure --with-compat --add-dynamic-module=$(passenger-config --nginx-addon-dir)代替)
./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --add-dynamic-module=$(passenger-config --nginx-addon-dir)
  1. Build the Passenger module and copy it to where Nginx can find it构建乘客模块并将其复制到 Nginx 可以找到的位置
make modules
sudo cp objs/ngx_http_passenger_module.so /usr/share/nginx/modules/
  1. Tell Nginx to load the module告诉 Nginx 加载模块
sudo nano /etc/nginx/nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log info;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
load_module "/usr/share/nginx/modules/ngx_http_passenger_module.so";
include /usr/share/nginx/modules/*.conf;

I also commented out the default server block.我还注释掉了默认服务器块。

  1. Configure my app (which is already unpacked in /var/www/myapp and I know from previous tests that it works with Nginx and Passenger installed from the repo)配置我的应用程序(它已经在 /var/www/myapp 中解压缩,我从之前的测试中知道它可以与 Nginx 和从 repo 安装的乘客一起使用)
sudo nano /etc/nginx/conf.d/myapp.conf

Extract from the conf file:从 conf 文件中提取:

server {

    listen 80;

    server_name myserveraddress;

    # Tell Nginx and Passenger where your app's 'public' directory is
    root /var/www/myapp/bundle/public;

    # Turn on Passenger
    passenger_enabled on;

    passenger_startup_file main.js;

    passenger_app_root /var/www/myapp/bundle;
...
  1. Restart nginx重启nginx
sudo service nginx restart

I now visit the web page but see a 404 not found page.我现在访问 web 页面,但看到 404 not found 页面。 In the logs I see only this:在日志中我只看到这个:

"/var/www/myapp/bundle/public/index.html" is not found (2: No such file or directory)

There are no other errors, warnings or info.没有其他错误、警告或信息。

This suggests to me that Nginx is loading my config file or it wouldn't be looking in /var/www/myapp/bundle.这向我表明 Nginx 正在加载我的配置文件,否则它不会在 /var/www/myapp/bundle 中查找。 But it doesn't seem to have enabled Passenger, as it's still looking for public/index.html instead of main.js.但它似乎没有启用乘客,因为它仍在寻找 public/index.html 而不是 main.js。

I can't find any way to inspect Nginx to see what dynamic modules are running, and I've tried setting the log level to debug.我找不到任何方法来检查 Nginx 以查看正在运行的动态模块,并且我尝试将日志级别设置为调试。 I'd be grateful for any suggestions how to find out what's going on / how to enable the Passenger module?我会很感激任何建议如何找出发生了什么/如何启用乘客模块?

I worked it out;我解决了; the issue was that I didn't realise that when you install Passenger as a dynamic module, you still need to do the same config as with a regular install.问题是我没有意识到当您将Passenger 作为动态模块安装时,您仍然需要进行与常规安装相同的配置。 In particular, in your nginx.conf, you need to add this to the http block:特别是,在您的 nginx.conf 中,您需要将其添加到 http 块中:

  passenger_root /usr/share/passenger-6.0.12;
  passenger_ruby /usr/bin/ruby;

passenger_root should be where your passenger is installed, which you can find by running:乘客根应该是安装乘客的位置,你可以通过运行找到它:

passenger-config --root

And passenger_ruby is your ruby file.而passenger_ruby 是您的ruby 文件。

I hadn't previously understood that in all configurations, Passenger must be installed and the module file ngx_http_passenger_module.so is just the glue to tell nginx how to talk to it.我以前不明白,在所有配置中,Passenger 都必须安装,模块文件ngx_http_passenger_module.so只是告诉 nginx 如何与之交谈的粘合剂。 Without passenger_root, nginx will act as though the passenger module is not installed.如果没有passenger_root,nginx 将像没有安装乘客模块一样工作。

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

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