Nginx Upgrade

nginxToday I needed to update my nginx server to support serving of static gzipped asset files alongside Passenger (Rails 3.1 asset pipeline - server configuration). My install was already a bit of a hack after trying various ways to originally get it installed. This update needed the whole thing to be re-built from source so I decided to get the latest source and write myself some notes so that it won't be so hard next time.

Inspiration came from this excellent blog post: How to compile your own Nginx and Passenger

Based on that blog post I just downloaded the source from nginx then wrote myself this little shell script.
--- build.sh ---#!/bin/bash
# Load RVM Functions into shell
[[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
#
rvm use ree
rvm current
#
echo passenger gem is installed in:
passenger-config --root
echo
export PASSENGER_NGINX_DIR=`passenger-config --root`/ext/nginx
echo PASSENGER_NGINX_DIR=$PASSENGER_NGINX_DIR
#
NGINX_SRC_DIR=`pwd`/nginx-1.0.8/
echo Building $NGINX_SRC_DIR
#
cd $NGINX_SRC_DIR
./configure \
--prefix=/usr/local \
--sbin-path=/usr/sbin \
--conf-path=/etc/nginx/nginx.conf \
--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 \
--add-module=$PASSENGER_NGINX_DIR
make
make install
#
echo All done. Just edit /etc/nginx/nginx.conf to ensure it is
echo picking up correct version of Passenger

 

Next time all I need to do is edit this script.