Thursday, August 30, 2007

Trac on FreeBSD6.2 w/ Subversion.

Recently I investigated using Trac (http://trac.edgewall.org/) integrating subversion built on FreeBSD front ended by Apache22. The reason behind this is simple, several of the projects that I am involved with need to use svn and also house web / wiki / forum capabilities. I have written this with the intent of helping FreeBSD users get a base functional install using the aforementioned technologies.

First things first, let's build Apache and Subversion with the appropriate options:
secure# cd /usr/ports/www/apache22
secure# make WITH_AUTH_MODULES=yes WITH_DAV_MODULES=yes \
WITH_SSL_MODULES=yes WITH_BERKELEYDB=db42 install clean
secure# cd /usr/ports/devel/subversion
secure# make -DWITH_SVNSERVE_WRAPPER -DWITH_MOD_DAV_SVN \
-DWITH_APACHE2_APR install clean
Now, let's prepare and build or repository
secure# mkdir -p /svn/repos
secure# svnadmin create /svn/repos
secure# chown -R www:www /svn/repos
After we build our repo and set permissions for www to access them, we need to setup our apache to use dav_svn_module and authz_svn_module. You will need to edit /usr/local/etc/apache22/httpd.conf and modify as noted in the excerpt from mine. Note the commented out dav_module (don't forget to do this or it's gonna break stuff later on)
.....
LoadModule usertrack_module libexec/apache22/mod_usertrack.so
LoadModule unique_id_module libexec/apache22/mod_unique_id.so
LoadModule setenvif_module libexec/apache22/mod_setenvif.so
LoadModule version_module libexec/apache22/mod_version.so
LoadModule ssl_module libexec/apache22/mod_ssl.so
LoadModule mime_module libexec/apache22/mod_mime.so
LoadModule dav_module libexec/apache22/mod_dav.so
LoadModule status_module libexec/apache22/mod_status.so
LoadModule autoindex_module libexec/apache22/mod_autoindex.so
LoadModule asis_module libexec/apache22/mod_asis.so
LoadModule info_module libexec/apache22/mod_info.so
.......
LoadModule alias_module libexec/apache22/mod_alias.so
LoadModule rewrite_module libexec/apache22/mod_rewrite.so
#LoadModule dav_module libexec/apache22/mod_dav.so
LoadModule dav_svn_module libexec/apache22/mod_dav_svn.so
LoadModule authz_svn_module libexec/apache22/mod_authz_svn.so
Next we will be creating our /usr/local/etc/apache22/Includes/svn.conf
secure# vi /usr/local/etc/apache22/Includes/svn.conf

DAV svn
SVNPath /svn/repos
AuthType Basic
AuthName "Feloo Subversion Repository"
AuthUserFile /etc/svn-auth-file
Require valid-user
Create our auth file using htpasswd
secure# htpasswd -cm /etc/svn-auth-file JJC
Build Trac from the ports tree
secure# cd /usr/ports/www/trac && make install clean
Create and initialize our environment
secure# mkdir -p /trac/projects/
secure# trac-admin /trac/projects initenv
secure# chown -R www:www /trac/projects/
Build mod_python3
secure# cd /usr/ports/www/mod_python3 && make install clean
Add one last module to our /usr/local/etc/apache22/httpd.conf
secure# vi /usr/local/etc/apache22/httpd.conf
LoadModule python_module libexec/apache22/mod_python.so
Define our trac location in /usr/local/etc/apache22/Includes/trac.conf (you'll have to create it)
secure# vi /usr/local/etc/apache22/Includes/trac.conf


SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /trac/projects
PythonOption TracUriRoot /trac


AuthType Basic
AuthName "JJC Trac Projects"
AuthUserFile /etc/svn-auth-file
Require valid-user

Now, start (or restart) your apache daemon
apachectl start
You should now be able to access Trac at http://theinstallediporhostname/trac

Cheers,
JJC

No comments:

Post a Comment