Skip to content

Instantly share code, notes, and snippets.

@paceline
Created August 13, 2013 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paceline/6219385 to your computer and use it in GitHub Desktop.
Save paceline/6219385 to your computer and use it in GitHub Desktop.
Human script for passenger w/ nginx - with the update frequency of both nginx and passenger recompiling the two can become quite a regular task. Here's what I usually do. Should work more or less like that on any Linux/Unix system.

Prerequisites

Ruby environment set up and configured, including passenger gem nginx source downloaded and extracted to /usr/local/src or wherever build-essential, curl and other basic development packages installed

"Solution"

Run passenger installer

passenger-install-nginx-module

Pick the 2nd (custom) option when it asks for how to install. It'll subsequently ask for your nginx source directory. Type in wherever you extracted it (see prerequisites above) When the install asks for custom configuration options, I like to use:

--with-http_ssl_module --with-debug --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --http-scgi-temp-path=/var/lib/nginx/scgi --with-http_stub_status_module --user=www-data --group=www-data --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-ipv6

Set up init.d script

wget http://nginx-init-ubuntu.googlecode.com/files/nginx-init-ubuntu_v2.0.0-RC2.tar.bz2

tar --use-compress-program bzip2 -xvf nginx-init-ubuntu_v2.0.0-RC2.tar.bz2

mv nginx /etc/init.d

chmod +x /etc/init.d/nginx

update-rc.d -f nginx defaults

Set up logrotate.d

vi /etc/logrotate.d/nginx

/var/log/nginx/*.log {
        weeklymissingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
        endscript
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment