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

5 comments:

Anonymous said...

Hi, useful post.
If possible I would like to know, if a similar setup can get rid of Berkeley DB.
In my case I already have a working installation of subversion using FS and I would like to install trac, but install from port fails and while trying to install first devel/apr-svn it start downloading and installing db42.
Thanks

JJC said...

I'll have to see what I can do, give me just a bit to play around with it and I'll let you know. Feel free to hit me up on #freenode, I can generally be found lurking around #snort, #inprotect or a few others :-)

Cheers,
J

Anonymous said...

I followed this thinking it look thorough and clear - however its pants.

Build failing all over the place installing ports that conflict with later ports and incomplete configuration

JJC said...

Can you tell me exactly where you experienced the issue? I have performed many installations using the exact steps mentioned and also am aware of several of my readers that have been successful with it. Of course if something has changed in the ports tree recently, this is a possibility.

I will be running a test install with the latest ports tree tomorrow to test this and will followup.

Again, if you can please provide details of the build failure(s) and architecture etc...

Cheers,
JJC

cRaY3 said...

Thanks a ton :)
after hours of pulling my hair with svn and trac, your guide finally made me setup the whole stuff in matter of few mins..thanks .