Skip to content

Server notes

How to install Phusion Passenger and Nginx from source

The nginx build script I use to compile Passenger into the nginx binary, with notes on passenger config values and RVM.

By Jozsef 2 min read

I keep a small script that compiles the latest nginx. This version extends the build so that Phusion Passenger is compiled into the nginx binary.

Here is the compiler script:

bash
#!/bin/sh
VERSION=1.8.0
p=`pwd`
gem update passenger

cd /usr/local/src
rm nginx-$VERSION.tar.gz
NGINX_SRC_DIR=/usr/local/src/nginx-$VERSION/
rm -rf $NGINX_SRC_DIR
wget http://nginx.org/download/nginx-$VERSION.tar.gz
tar -xzvf nginx-$VERSION.tar.gz
cd $NGINX_SRC_DIR
./configure --sbin-path=/usr/sbin/nginx \
  --pid-path=/var/run/nginx.pid \
  --lock-path=/var/lock/nginx.lock \
  --conf-path=/etc/nginx/nginx.conf \
  --user=www-data --group=www-data \
  --error-log-path=/var/log/nginx/error.log \
  --http-log-path=/var/log/nginx/access.log \
  --with-http_ssl_module \
  --with-http_gzip_static_module \
  --without-http_ssi_module \
  --without-http_userid_module \
  --without-http_upstream_ip_hash_module \
  --without-http_uwsgi_module \
  --without-http_scgi_module \
  --without-http_split_clients_module \
  --without-http_referer_module \
  --without-http_memcached_module \
  --without-http_browser_module \
  --with-mail_ssl_module \
  --with-mail \
  --without-mail_smtp_module \
  --with-pcre \
  --with-http_stub_status_module \
  --without-http_charset_module \
  --without-http_geo_module \
  --without-http_map_module \
  --add-module=`passenger-config --nginx-addon-dir`

make

Change the configuration to match your server. The nginx make install step backs up the current binary, but I still keep a manual copy. I also stop monit before the install because I want control over when nginx restarts.

Before restarting nginx, add the passenger_root and passenger_ruby directives to the nginx configuration. Passenger reports both values:

bash
$ passenger-config about root
/usr/local/rvm/gems/ruby-2.2.2/gems/passenger-5.0.14

$ passenger-config about ruby-command
passenger-config was invoked through the following Ruby interpreter:
  Command: /usr/local/rvm/gems/ruby-2.2.2/wrappers/ruby
  Version: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
  To use in Apache: PassengerRuby /usr/local/rvm/gems/ruby-2.2.2/wrappers/ruby
  To use in Nginx : passenger_ruby /usr/local/rvm/gems/ruby-2.2.2/wrappers/ruby
  To use with Standalone: /usr/local/rvm/gems/ruby-2.2.2/wrappers/ruby /usr/local/rvm/gems/ruby-2.2.2/gems/passenger-5.0.14/bin/passenger start

Notes for RVM users

If you need the command for a different Ruby interpreter, run rvm use with that interpreter and then run passenger-config about ruby-command again.

Once nginx works, turn monit back on. It will probably complain that the nginx binary checksum changed.

Sources and further reading