Install Trac on Ubuntu 12.04 with Nginx

This post is similar to my previous post about installing Trac with Apache. Nginx is now my preferred web server cuz its way faster and light weight.

Install trac package:

sudo apt-get install trac trac-git

Configure a new trac project enviroment:

sudo mkdir -p /var/trac/myproject cd /var/trac/myproject sudo trac-admin . initenv sudo htpasswd -c .htpasswd adminusername sudo trac-admin . permission add adminusername TRAC_ADMIN sudo chown -R www-data: .

Configure nginx:

server { listen 80; proxypass http://localhost:10001/; authbasic "Dev"; authbasicuserfile htpasswd; proxypass_header Authorization; }

Create a new init.d script: /etc/init.d/tracd

#! /bin/sh ### BEGIN INIT INFO # Provides: tracd # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the tracd web server # Description: starts tracd using start-stop-daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/tracd NAME=tracd DESC=tracd DAEMONOPTS="-p 10001 --protocol=http -e /var/trac --basic-auth *,/etc/nginx/htpasswd,Dev" test -x $DAEMON || exit 0 # Include tracd defaults if available if [ -f /etc/default/tracd ] ; then . /etc/default/tracd fi set -e case "$1" in start) echo -n "Starting $DESC: " start-stop-daemon --start --quiet --pidfile /var/run/$ \ --chuid www-data --background --make-pidfile \ --exec $DAEMON -- $DAEMONOPTS echo "$NAME." ;; stop) echo -n "Stopping $DESC: " start-stop-daemon --stop --quiet --pidfile /var/run/$ echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " start-stop-daemon --stop --quiet --pidfile /var/run/$ sleep 1 start-stop-daemon --start --quiet --pidfile /var/run/$ \ --chuid www-data --background --make-pidfile \ --exec $DAEMON -- $DAEMON_OPTS echo "$NAME." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 exit 1 ;; esac exit 0

sudo chmod +x /etc/init.d/tracd sudo /usr/sbin/update-rc.d -f tracd defaults

Paul Soucy

Read more posts by this author.