Recipe: Trac via Nginx-front
Tuesday, April 23. 2013
I'm a fan of Trac wiki / issue tracker. It has the correct price (free) combined with all the features I need in software development. Since all my Linux-development is done in RHEL / CentOS -environment, getting a Trac to run requires tweaking. Also after our production server hit the 10k-connection limit and we had to change to Nginx, I don't have any Apache daemons running. Given that constraint, I definitely need some tweaking of my own.
Software needed:
- Nginx, get my RPM from http://opensource.hqcodeshop.com/CentOS/6%20x86_64/Nginx/
- uWSGI, get my RPM from http://opensource.hqcodeshop.com/CentOS/6%20x86_64/uWSGI/
- Trac, get my RPM from http://opensource.hqcodeshop.com/Trac/
Setup:
Traci is built with Python, but it is typically installed anyway. uWSGI is the glue between Nginx and a Python app. My uWSGI should run out of the box. It defaults to seeing Python apps in directory /var/www/uwsgi/, so make sure to create the Trac parent file trac_env_parent.py into it:
# -*- coding: utf-8 -*-
# file: trac_env_parent.wsgi
import sys
sys.stdout = sys.stderr
import os
os.environ['TRAC_ENV_PARENT_DIR'] = '/var/www/uwsgi/trac'
os.environ['PYTHON_EGG_CACHE'] = '/var/www/uwsgi/.egg-cache'
import trac.web.main
application = trac.web.main.dispatch_request
Also it is a good idea to make sure, that uwsgi-user can write into the .egg-cache-directory. Permissions should be:
drwxr-xr-x. 2 uwsgi uwsgi 4096 Jan 8 2012 .egg-cache
Then bind Nginx into uWSGI-app. In my case I defined a virtual host for that. Fragment of nginx.conf:
server {
listen [::]:80;
server_name my.trac.own.com;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
}
}
The file /etc/nginx/uwsgi_params is something out of a default Nginx source. I didn't change anything in it.
After that it's only getting the Trac properly configured with your DB-backend and filesystem.
What others are doing: