[英]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
我是如何構建模塊的:
sudo dnf install passenger-devel.x86_64
sudo /usr/bin/passenger-config validate-install
這顯示“一切看起來都不錯”
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
sudo yum install pcre-devel
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
wget https://nginx.org/download/nginx-1.20.1.tar.gz
tar zxf nginx-1.20.1.tar.gz
cd nginx-1.20.1/
nginx -V
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)
make modules
sudo cp objs/ngx_http_passenger_module.so /usr/share/nginx/modules/
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;
我還注釋掉了默認服務器塊。
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;
...
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.