| 1 | == Recipe - Configuring Apache 2 on CentOS-4.2 to serve trac == |
| 2 | |
| 3 | HOWTO: |
| 4 | Set up Apache 2 to access a trac environment on CentOS-4.2 |
| 5 | |
| 6 | 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. |
| 7 | |
| 8 | 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. |
| 9 | |
| 10 | 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. |
| 11 | |
| 12 | 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' |
| 13 | |
| 14 | |
| 15 | {{{ |
| 16 | <VirtualHost *> |
| 17 | DocumentRoot "/var/data/trac" |
| 18 | ServerName trac.mydomain.tld |
| 19 | <Directory "/var/data/trac"> |
| 20 | allow from all |
| 21 | Options +Indexes |
| 22 | </Directory> |
| 23 | <Location /> |
| 24 | SetHandler mod_python |
| 25 | PythonHandler trac.web.modpython_frontend |
| 26 | PythonOption TracEnv /var/data/trac |
| 27 | SetEnv PYTHON_EGG_CACHE /var/data/trac/cache |
| 28 | PythonOption TracUriRoot / |
| 29 | </Location> |
| 30 | <Location "/conf"> |
| 31 | AuthType Basic |
| 32 | AuthName "tld.mydomain" |
| 33 | AuthUserFile /var/data/trac/conf/trac.htdigest |
| 34 | Require valid-user |
| 35 | </Location> |
| 36 | </VirtualHost> |
| 37 | }}} |
| 38 | |
| 39 | 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. |
| 40 | |
| 41 | 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. |
| 42 | |