Setup Subversion and Trac on CentOS 5
Recently I set up a virtual server to use as a development machine. It runs on CentOS 5 and hosts several Subversion repositories with associated Trac projects.
There are many guides and plenty of help on the net to help you setup such a system. However, when I tried to do it I came across a few problems and I hope this post may help at least a few people trying to do the same as me. I am not going to rewrite the great tutorials out there, I will just point you to them and note what things I did differently.
This 'guide' should get you from a fresh install of CentOS 5 linux to one or more working Subversion (SVN) repositories and associated Trac wiki's. Apache/WebDAV is used as the network layer. I have only tested this on a fresh install of CentOS 5.
The Environment
I am aiming for the following:
- CentOS 5, SVN installed. Apache2 as the network layer using mod_dav_svn.
- Trac running on Apache with mod_python
- SVN repositories located at: /srv/svn (e.g. /srv/svn/my-project), accessible via http://server/svn/my-project
- Trac projects located at: /srv/trac (e.g /srv/trac/my-project) accessible via http://server/trac/my-project
How I did it
Not all the steps are vital (probably) but this is how I got it working. Feel free to skip any non-relevant steps (i.e. there is probably no need for a fresh install). Replace any occurence of <project> with the name of your first project.
1. Fresh install of CentOS. I followed most of the Perfect Setup Guide, except the mail and ISPConfig stuff. The important part is setting up the Apache2 web server.
2. Make sure SVN and mod_dav_svn are installed. As root:
yum install subversion mod_dav_svn
vim /etc/httpd/conf/httpd.conf
If the following two lines are not present, add them:
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
3. Install Trac: Follow Nick's guide with the alternative Clearsilver installation below. Skip the Apache Configuration part.
Follow all of parts 1 and 2. Instead of part 3 do:
wget http://dag.wieers.com/rpm/packages/clearsilver/clearsilver-0.10.4-1.el5.rf.i386.rpm rpm -i clearsilver-0.10.4-1.el5.rf.i386.rpm wget http://dag.wieers.com/rpm/packages/clearsilver/python-clearsilver-0.10.4-1.el5.rf.i386.rpm rpm -i python-clearsilver-0.10.4-1.el5.rf.i386.rpm
Continue with parts 4.1 and 4.2 of Nick's guide. Remember, leave out Apache configuration section.
4. Create your first SVN Repository:
svnadmin create --fs-type fsfs /srv/svn/<project>
5. Initialise a Trac project for your new repository:
trac-admin /srv/trac/<project> initenv
For the trac-admin command use the defaults if not sure, giving a descriptive name for the project. The `Path to repository` is: /srv/svn/<project>.
6. Set the correct file permissions for apache
chown -R apache.apache /srv/svn/<project> chown -R apache.apache /srv/trac/<project>
7. Tell apache where to find the new repository. Here we create an additional Apache configuration file specifically for the SVN repositories.
vim /etc/httpd/conf.d/subversion.conf
Add the following directive:
<Location /svn/<project>> DAV svn SVNPath /srv/svn/<project> AuthType Basic AuthName "<project> Repository" AuthzSVNAccessFile /srv/svn/svn-acl-conf AuthUserFile /srv/svn/<project>.htpasswd Require valid-user </Location>
8. Add a repository user:
touch /srv/svn/<project>.htpasswd htpasswd -m /srv/svn/<project>.htpasswd <username>
9. Create the Access Control List for the SVN Repository
vim /srv/svn/svn-acl-conf
Add the following directives:
[<project>:/] <username> = rw
Where <username> represents the username of the repository user you created earlier.
10. Tell apache where to find the new Trac project. Here we create an additional Apache configuration file specifically for the Trac projects.
vim /etc/httpd/conf.d/trac.conf
Add the following directives:
<Location /trac/<project>> SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnv /srv/trac/<project> PythonOption TracUriRoot /trac/<project> </Location> <Location "/trac/<project>/login"> AuthType Basic AuthName "trac" AuthUserFile /srv/trac/<project>.htpasswd Require valid-user </Location>
11. Add a Trac user:
touch /srv/trac/<project>.htpasswd htpasswd -m /srv/trac/<project>.htpasswd <username>
12. Give admin permissions to the Trac user you just created:
trac-admin /srv/trac/<project> permission add <username> TRAC_ADMIN
Where <username> represents the username of the Trac user you just created.
13. Restart Apache:
service httpd restart
You should now have SVN and Trac installed. You will have an SVN repository setup (http://server/svn/<project>) and the Trac wiki (http://server/trac/<project>) associated with the repository.
Please let me know if this helped you. If you come across any problems I will be happy to try and help.
Resources
The last part of CentOS HowTos: Subversion will give you a quick introduction on how to use SVN.
Subversion setup guides: here and here
Trac setup guides: here and here.
ClearSilver template system (used by Trac).
Posted by Daniel Skinner 6 months ago
Tags: centos, Guides, subversion, trac, tutorial, version control













Comments
Thanks a lot, just tried this out, left out the trac install, worked first time.
Great howto. Thanks. One small change on your item 4…
svnadmin create -fs-type fsfs /srv/svn/
should be:
svnadmin create –fs-type fsfs /srv/svn/
Note the double dash in front of fs-type.
Regards,
PC
I’m glad it helped you out.
Thanks for reporting the error, I will fix it right away.
This saved me a lot of work. Big Thanks!
Additionally to the steps above I had to add
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
to my /etc/httpd/conf/httpd.conf
otherwise I got
Unknown DAV provider: svn
One more thing (just in case anyone else is running into this)
I had to disable SELinux otherwise modpython couldn’t access /srv/trac//VERSION
Glad it helped you out. Thanks for the feedback, I will add that to the guide shortly.
When you yum install mod_dav_svn, you get /etc/httpd/conf.d/subversion.conf, so you don’t really need to make any subversion changes to httpd.conf. Edit /etc/httpd/conf.d/subversion.conf instead.
Thanks Daniel for posting this guide.
I tried to follow this tutorial (but skipped the Trac steps) and just came up some problem on my Centos 5 (latest one)
1. I added these lines
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
the apache did not start until I added an other line:
LoadModule dav_module modules/mod_dav.so
2. Everything seem work fine, I can see the successful message as below when type http://localhost/svn
Revision 0: /
——————————————————
Powered by Subversion version 1.4.2 (r22196).
the problem is that i could not able to create, edit or commit the file to repository.
Here is the error message:
Can’t create directory ‘/subversion/svn/db/transactions/0-1.txn’: Permission denied.
Anyone have idea why this happended?
Cheers
Can you create, edit or commit from a command line?
If you can then you might need to ensure the user which apache is running as has permission to write to the files.
On my version apache is the user, so I would try something like:
chown -R apache.apache /subversion/svn/
Let me know it that works!
Hi Daniel,
Thanks for your reply.
1. I could not create, edit or commit from command line at all.
2. Not sure which version apache is for user or root, but all the steps (your guides) above were done under ROOT account
I typed this command line
# httpd -version
and got this respond
Server version: Apache/2.2.3
Server built: Nov 10 2007 12:44:14
3. I did try your suggestion
chown -R apache.apache /subversion/svn/
and also
chown -R apache.apache /subversion
but the same error message came back still.
I’m quite stumped :(
Please let me know if you have any other thoughts.
Cheers,
Dave
[...] Installing Trac on CentOS 5 I’m using Slicehost, but these instructions should work for any hosting provider running CentOS 5. I am not using Subversion (because it sucks and has been slain by Git). If you need SVN support, check out the posts by Nick or Daniel Skinner. [...]
Dave,
Do:
cd /subversion/svn/
ls -la
Do the permissions look reasonable?
If not, try doing a temporary hack: chmod -R 777 to see if that fixes the issue - if it does don’t leave it like that but at least we have identified it’s file/ownership permissions that is problematic.
Hi Daniel,
Thanks very much for helps. The problem was came from SELinux, it actually blocked users from accessing to httpd service.. Phew.. here is the error message from Setroubleshoot
SELinux prevented /usr/sbin/httpd from writing 10-1.txn.Detailed DescriptionSELinux prevented /usr/sbin/httpd from writing 10-1.txn.
If 10-1.txn is a core file, you may want to allow this. If 10-1.txn is not a core file, this could signal a intrusion attempt.
Allowing Access
Changing the “allow_daemons_dump_core” boolean to true will allow this access: “setsebool -P allow_daemons_dump_core=1.”
The following command will allow this access:
setsebool -P allow_daemons_dump_core=1
Please note that the suggestion does not work at all. I disable SELinux by editting /etc/selinux/config and change the SELINUX line to SELINUX=permissive:
Cheers mate.
I also thought I did fairly well. Everything seemed to install and restart, but I get this error
ClearSilver not installed (No module named neo_cgi)
when I browse to my trac url. However, if I go back and revisit the clearsilver rpm instructions, I’m told clearsilver IS already installed. Any ideas?
Try re-installing the python bindings:
wget http://dag.wieers.com/rpm/packages/ clearsilver/python-clearsilver-0.10.4-1.el5.rf.i386.rpm
rpm -i python-clearsilver-0.10.4-1.el5.rf.i386.rpm
Thanks Daniel that did the trick; we are now on Trac ;-)
[...] up a server to use as a development machine. From a standard CentOS 5 installation I have installed SubVersion and Trac. Now I have finally got round to installing phpUnderControl for continuous integration and build [...]
Hey awesome blog! Know anyone who would be interested in part time admin’ing a Linux box? Hit me up!
Hello,
Does this guide remain valid in case of virtual hosts configuration ?
Thanks
Emilien
Hi Emilien,
Yes, this guide will apply to a VHost setup.
You should be able to simply replace the Location directives with VirtualHost directives. The content of the directive remains the same with the addition of the servername and serveralias directives of course.
For the trac login you may want to place the location directive within the trac virtualhost if that is how you would like things setting up.
Let me know how it goes.
Daniel
Yeah, it works well !
Thank you Daniel.
Emilien