Compiling Nginx with Phusion Passenger on OSX
April 29th, 2009 | Design & Development |It took me a little while to get passenger set up with Nginx because I wanted to compile Nginx separately instead of using the tool provided with the passenger gem. I have it all working now so here’s how I did it. I’m running OSX Leopard but this should be fine on any Linux distro too.
sudo gem install passenger cd `passenger-config --root` rake nginx
Download latest stable nginx tarball. (currently 0.6.36) to the directory of your choice, then, in that directory
tar -xzf nginx-0.6.36.tar.gz cd nginx-0.6.36 ./configure --with-http_ssl_module --add-module=`passenger-config --root`/ext/nginx make sudo make install
OR
If you already have nginx installed you might just want to copy the nginx binary from objs/nginx and replace the existing nginx binary with that.
cp -f objs/nginx /usr/local/nginx/sbin/nginx
Edit the nginx.conf (should be in /usr/local/nginx/conf) to add passenger_root, again you can get this path with passenger-config --root.
Create a virtual host with a root in the rails app public dir and set passenger_enabled on; also set rails_env development;. It is important that the server root directive is set to the public directory of your rails app.
The following is an excerpt from my nginx.conf with passenger relevant config only:
http {
#
#
passenger_root /Library/Ruby/Gems/1.8/gems/passenger-2.2.2;
#
#
server {
listen 80;
server_name www.example.com;
root /some/path/to/my_rails_app/public;
passenger_enabled on;
rails_env development;
}
#
#
}









