我正在嘗試將 Phusion Passenger 安裝為從 repo 安裝的 Nginx 的動態模塊。該程序似乎正在運行,但我的 Meteor 應用程式沒有加載,并且看起來乘客模塊沒有運行。
作業系統:紅帽 8
Nginx:1.20.1
乘客:獨立 6.0.12
流星:2.5.1
我是如何構建模塊的:
按照教程獨立安裝Passenger
安裝乘客開發
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
- 安裝 PCRE
sudo yum install pcre-devel
- 從 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
- 下載 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
- Used the output of
nginx -Vto construct and then run theconfigurecommand (though as the output showed --wtih-compat I could probably have used./configure --with-compat --add-dynamic-module=$(passenger-config --nginx-addon-dir)instead)
./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)
- Build the Passenger module and copy it to where Nginx can find it
make modules
sudo cp objs/ngx_http_passenger_module.so /usr/share/nginx/modules/
- Tell Nginx to load the module
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.
- 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)
sudo nano /etc/nginx/conf.d/myapp.conf
Extract from the conf file:
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;
...
- Restart nginx
sudo service nginx restart
I now visit the web page but see a 404 not found page. 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.
這向我表明 Nginx 正在加載我的組態檔,否則它不會在 /var/www/myapp/bundle 中查找。但它似乎沒有啟用Passenger,因為它仍在尋找public/index.html而不是main.js。
我找不到任何方法來檢查 Nginx 以查看正在運行的動態模塊,并且我嘗試將日志級別設定為除錯。我會很感激任何建議如何找出發生了什么/如何啟用乘客模塊?
uj5u.com熱心網友回復:
我解決了;問題是我沒有意識到當您將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 會表現得好像沒有安裝passenger 模塊一樣。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/406923.html
標籤:
