Hosting Trac with Passenger and nginx
As well as being able to host Ruby applications with Rack, Phusion Passenger can also host Python applications with WSGI. This article shows how I set up Trac on Debian with nginx and Passenger.
I decided to use the Trac package available in the Debian repository,
installing it is done with a simple
You then need to create a Trac database. I decided to store it in /srv/trac but you can choose any location in which Passenger has read/write permissions. The command to run is:
You will be asked a series of questions including the name of the project, the database connection string (I left this as the default SQLite option), the type of repository and the path to the repository. These values will vary depending on your current setup.
The next step is to deploy the static files to the document root we will use in nginx. I store all my websites in /srv/www so used the following command:
This will create two sub-directories:
/srv/www/trac.grahamedgecombe.com/htdocs. However, Passenger expects a folder called
public and a script called
passenger_wsgi.py. The best way
to fix this is to create some symbolic links like so:
Configuring Passenger generally requires lines like the following in the
http block in your
The appropriate lines will have been given to you as part of the Passenger installation procedure.
I also include the following configuration in the
You should also consider configuring the pool size with
passenger_max_instances_per_app, the exact values you should use depend
on how many applications you are running with Passenger and how much memory
your server has.
Configuring a virtual server is relatively simple now and can be done by placing something like the following in your http block:
Once that is done, reboot nginx and everything should work.