簡體   English   中英

安裝 Phusion Passenger 作為動態 Nginx 模塊; 模塊似乎沒有加載但沒有錯誤

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

我正在嘗試將 Phusion Passenger 安裝為動態模塊,其中 Nginx 從 repo 安裝。 該過程似乎正在運行,但我的 Meteor 應用程序未加載,並且似乎乘客模塊未運行。

操作系統:紅帽 8

Nginx:1.20.1

乘客:獨立 6.0.12

Meteor:2.5.1

我是如何構建模塊的:

  1. 按照教程獨立安裝Passenger

  2. 安裝乘客開發

sudo dnf install passenger-devel.x86_64
  1. 檢查安裝
sudo /usr/bin/passenger-config validate-install

這顯示“一切看起來都不錯”

  1. 檢查乘客模塊路徑
passenger-config --nginx-addon-dir

返回

/usr/share/passenger/ngx_http_passenger_module

sudo ls /usr/share/passenger/ngx_http_passenger_module

節目

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. 安裝 PCRE
sudo yum install pcre-devel
  1. 從 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. 下載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. 檢查編譯標志:
nginx -V
  1. 使用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. 構建乘客模塊並將其復制到 Nginx 可以找到的位置
make modules
sudo cp objs/ngx_http_passenger_module.so /usr/share/nginx/modules/
  1. 告訴 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;

我還注釋掉了默認服務器塊。

  1. 配置我的應用程序(它已經在 /var/www/myapp 中解壓縮,我從之前的測試中知道它可以與 Nginx 和從 repo 安裝的乘客一起使用)
sudo nano /etc/nginx/conf.d/myapp.conf

從 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. 重啟nginx
sudo service nginx restart

我現在訪問 web 頁面,但看到 404 not found 頁面。 在日志中我只看到這個:

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

沒有其他錯誤、警告或信息。

這向我表明 Nginx 正在加載我的配置文件,否則它不會在 /var/www/myapp/bundle 中查找。 但它似乎沒有啟用乘客,因為它仍在尋找 public/index.html 而不是 main.js。

我找不到任何方法來檢查 Nginx 以查看正在運行的動態模塊,並且我嘗試將日志級別設置為調試。 我會很感激任何建議如何找出發生了什么/如何啟用乘客模塊?

我解決了; 問題是我沒有意識到當您將Passenger 作為動態模塊安裝時,您仍然需要進行與常規安裝相同的配置。 特別是,在您的 nginx.conf 中,您需要將其添加到 http 塊中:

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

乘客根應該是安裝乘客的位置,你可以通過運行找到它:

passenger-config --root

而passenger_ruby 是您的ruby 文件。

我以前不明白,在所有配置中,Passenger 都必須安裝,模塊文件ngx_http_passenger_module.so只是告訴 nginx 如何與之交談的粘合劑。 如果沒有passenger_root,nginx 將像沒有安裝乘客模塊一樣工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM