Installing Passenger Nginx module on FreeBSD

Currently (at least when I wrote this article) the FreeBSD ports system didn't contain a port for the Passenger Nginx module to deploy a Ruby on Rails application in the Nginx webserver, but it did contain all the necessary components. It is rather simple the use the nginx and rubygem-passenger from the port system and enable passenger support in Nginx.

To enable the passenger module in Nginx do the following:

1) make sure your ports tree is up to date (portsnap fetch; portsnap update).

2) install the ruby-gems port (cd /usr/ports/devel/ruby-gems; make install clean).

When I wrote this article the latest version of the ruby-gems port was 1.3.1, this version is not compatible with the Passenger module so update rubygems if necessary (gem update --system).

3) install the passenger module (cd /usr/ports/www/rubygem-passenger; make install clean) or (gem install passenger).

4) Include the path to the Nginx Passenger module in the Makefile of the Nginx port (to find the correct path to the passenger module use the command passenger-config—root and add /ext/nginx to the displayed path) by adding the following line to the CONFIGURE_ARGS macro around line 54: --add-module=/usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/nginx or download this and patching the Makefile with: patch -p0 < passenger.patch

5) Enable other nginx modules if necessary (cd /usr/ports/www/nginx; make config)

6) Install the nginx port (cd /usr/ports/www/nginx; make install clean)

7) Install Rails and any other gem modules your ROR project may need.

You can now enable / configure Nginx the usual way, and configure a virtual host for your Rails application following the instructions from the passenger website

I hope the port maintainer of Nginx will change the Makefile soon, so that you will be able to select the passenger module from within the make config menu.

If you have any question please feel free to add a comment to this article.

Johan

Posted by Johan Bakker on Saturday, May 16, 2009

digg delicious technorati blinklist furl reddit