Answer a question

I'm trying to install Phusion Passenger as a dynamic module with Nginx installed from the repo. The process seems to be working but my Meteor app doesn't load and it looks like the Passenger module isn't running.

OS: RedHat 8

Nginx: 1.20.1

Passenger: Standalone 6.0.12

Meteor: 2.5.1

How I've built the module:

  1. Install Passenger standalone as per the tutorial

  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
sudo yum install pcre-devel
  1. Install Nginx from repo
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
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)
./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
make modules
sudo cp objs/ngx_http_passenger_module.so /usr/share/nginx/modules/
  1. 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.

  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)
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;
...
  1. 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.

This suggests to me that Nginx is loading my config file or it wouldn't be looking in /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.

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. I'd be grateful for any suggestions how to find out what's going on / how to enable the Passenger module?

Answers

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. In particular, in your nginx.conf, you need to add this to the http block:

  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.

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. Without passenger_root, nginx will act as though the passenger module is not installed.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐