For some reason or another I could not find good documentation on installing Subversion and Trac on fc6 while also using Apache so I’ve simply just documented what I’ve learned and just implemented on my own system.
This tutorial is about the installation of a development enviroment on FC6 it’s not a how-to for using it. If you need to know more I recommend reading Version Control with Subversion (I just ordered it).
Requirements
You need to install these packages before we start (use yum install package-name).
- Trac – documentation wiki and bug-tracking software.
- Subversion – source code control system.
- Apache – duh.
/home/svn
I’ve gone ahead and installed this development environment in /home/svn not /srv/ or var/www like other resources prefer. If you want to install svn in a different directory please change the below instruction appropriately.
Subversion
Within you’ll need to create a new, empty subversion repository. Do this by running this command
$ svnadmin create /home/svn
You’ll need to establish the trunk/tags/branches directory structure. Create a temporary directory somewhere, i.e. /tmp/newsvn. Go there and create three subdirectories called, “branches” “tags” and “trunk”. Then import those directories into svn
$ svn import /tmp/newsvn file:///home/svn -m “initial import”
The terminal should print
Adding /tmp/newsvn/trunk
Adding /tmp/newsvn/branches
Adding /tmp/newsvn/tags
Committed revision 1.
Subversion now works and can be accessed by going to http://localhost/svn. If you’re receiving an error 13 it’s caused by permissions problems and running the below command will clear it up,
$ chcon -R -h -u system_u -t httpd_sys_content_t /home/svn
Trac environment
Before you start you’ll want to create a directory for trac. I prefer to have it within my SVN directory,
$ mkdir -p /home/svn/trac
To initiate trac you will need to run,
$ trac-admin /home/svn/trac initenv
To create the new enviroment you will be ask a few questions. The only two that you should be concerned with are
Project Name [My Project]> Trac
This is exactly what it says, just name it anything you want.
Path to repository [/path/to/repos]> /home/svn
This is important. Make sure to enter the full path to svn, if you’re using my settings enter /home/svn.
All of the other questions just press enter as the default settings work fine in our setup.
Authentication
I password protect both Trac and Subversion through basic authorization and store the passwords in an htpasswd file in within SVN. I wont go to deep into this how you can create more users and groups, that’s what Google is for,
$ htpasswd -cb /home/svn/htpasswd username password
Trac and Apache Setup
I recommend an entire virtual host for trac, with a name of trac.domain.com
<VirtualHost IPAddress:*>
ServerName trac.domain.com
DocumentRoot /home/svn/trac
SetEnv TRAC_ENV “/home/svn/trac”
Alias /trac/ /usr/share/trac/htdocs/
<Directory /usr/share/trac/htdocs>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAliasMatch ^/(.*) /usr/share/trac/cgi-bin/trac.cgi/$1
<Location “/”>
AuthType Basic
AuthName “Trac”
AuthUserFile /home/svn/htpasswd
Require valid-user
</Location>
</VirtualHost>
The trac_env declaration is necessary for Trac to know where it lives, and the ScriptAliasMatch maps all access into the domain.
In order for Trac to make changes, which is pretty much the whole point, you have to grant write access for the apache user to the trac/db
subdirectory. Run,
$ chmod -R g+w /home/svn/trac/db
Then chown it to be owned by the apache user.
$ chown -R apache /home/svn/trac/db
Now you add a trac admin. Use trac-admin to add overall administration rights.
trac-admin trac
permission add username TRAC_ADMIN
Subversion and Apache setup
Although you you’re already accessed Subversion from the local filesystem, it’s time to setup Apache2 to give it a domain. Here is my Virtual Host setup,
<VirtualHost IPaddress:*>
ServerName svn.domain.com
DocumentRoot /home/svn
<Directory /home/svn>
AllowOverride All
Options MultiViews -Indexes Includes FollowSymlinks
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
# WebDAV access
<Location />
DAV svn
SVNPath /home/svn
AuthType Basic
AuthName “SVN”
AuthUserFile /home/svn/htpasswd
Require valid-user
# Allow read-only access to anyone, otherwise require
# authentication
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
</VirtualHost>
The LimitExcept will grant read-only access to any anonymous user; any other command the user will need to provide authentication.
Now you just need to make the whole Subversion repository writable, if you intend to accept checkins from others. So again run,
$ chmod -R g+w /home/svn/trac/db
$ chown -R apache /home/svn/trac/db
That’s It!
Here are some great resources for SVN and Trac:
