Edgewall Software

Version 1 (modified by byrnejb@…, 18 years ago) ( diff )

Added ne recipe

Recipe - Configuring Apache 2 on CentOS-4.2 to serve trac

HOWTO: Set up Apache 2 to access a trac environment on CentOS-4.2

Although there are many discussions of seting up trac with Apache of course none of them covered my exact situation. So I am providing YAATX (Yet Another Apache-Trac eXample) for your viewing enjoyment.

Getting trac to work with Apache is not terribly difficult, but there are a number of bits to deal with. As one place is a good as another we will start with the DSO modules for Apache. Happily, mod_python is provided for by the default Apache 2 configuration on CentOS-4.2. The configuration file is found at /etc/httpd/conf.d/python.conf and, as the settings in the default seem to serve, you can forget about modifying your conf/httpd.conf file for now.

Next, there is the issue of permissions on both the trac environment and the subversion repository. Afer several takes on this I came to the conclusion that it would be best to create separate users and groups for trac and subversion called, originally enough, trac:trac and svn:svn. I then set the ownerships on the trac environment and subversion repositories to trac:trac and svn:svn respectively. I next added the apache user as a member to both the trac and svn groups. This allows apache to read the files in both these directory structures.

The final bit is to create a file called something like '/etc/httpd/conf.d/trac.conf' and place your httpd directives for trac and python in it. In my case I set up a virtual server called trac.mydomain.tld and put the following lines in a file called '/etc/httpd/conf.d/trac.mydomain.tld.conf'. Note that the trac environment is located at '/var/data/trac'

<VirtualHost *>
DocumentRoot "/var/data/trac"
ServerName trac.mydomain.tld
<Directory "/var/data/trac">
allow from all
Options +Indexes
</Directory>
<Location />
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /var/data/trac
   SetEnv PYTHON_EGG_CACHE /var/data/trac/cache
   PythonOption TracUriRoot /
 </Location>
 <Location "/conf">
   AuthType Basic
   AuthName "tld.mydomain"
   AuthUserFile /var/data/trac/conf/trac.htdigest
   Require valid-user
 </Location>
</VirtualHost>

The AuthName directive refers to the realm used when creating the htdigest file for user authentication. I had to create the egg.cache inside the trac enviroment to avoid permission problems in the /var/www/htdocs directory. The 'TracUriRoot /' is required so that trac can find its support files like stylesheets and plugins, '/' in this case equates to '/var/data/trac'. The user password file is created with the htdigest(1) program.

This set up does not yet employ cgi or fastcgi so it will be slow. When I get to the point of using mod_fcgid then "I'll be back" with the details.

Note: See TracWiki for help on using the wiki.