Installing Passenger as a normal or dynamic Nginx module

Static module

If you have ever installed a static add-on module for Nginx, then you know that it involves the following steps:

  1. Download the Nginx source code.
  2. Run the Nginx configure script with --add-module parameters, like this: ./configure --prefix=/somewhere --add-module=/path-to-your-module
  3. Run make && sudo make install to compile and install Nginx.

This is actually exactly what passenger-install-nginx-module does under the hood. It compiles Nginx with --add-module=/path-to-passenger-module.

The value for /path-to-passenger-module can be obtained with the command:

$ passenger-config --nginx-addon-dir

Here is a full example that shows, given an Nginx source directory, how you can install Nginx with Passenger enabled as well as any other Nginx module you want:

$ cd /path-to-nginx-source-dir
$ ./configure --prefix=/opt/nginx \
  --add-module=$(passenger-config --nginx-addon-dir) \
  --add-module=/path-to-some-other-nginx-module
$ make
$ sudo make install

Dynamic module

Nginx 1.9.11 and later support dynamic modules. Passenger 5.0.28 and later supports this. Like compiling Passenger as a static module, compiling Passenger as a dynamic module requires the Nginx source code.

You can install Passenger as a dynamic module as follows:

$ cd /path-to-nginx-source-dir
$ ./configure --prefix=/opt/nginx \
  --add-dynamic-module=$(passenger-config --nginx-addon-dir) \
  --add-module=/path-to-some-other-nginx-module
$ make
$ sudo make install

After running the above command, make sure that Nginx loads the Passenger module by specifying this in your Nginx configuration file:

load_module modules/ngx_http_passenger_module.so;