Previously I have installed a DNS service on my Ubuntu server. Today I would like to install a Trac service which supports for multiple projects using Mod_Python on Apache.
Condition :
- I would like to use sub-domain for trac service that is trac.aoddy.com
- Trac service can support multiple projects such as trac.aoddy.com/Project1, trac.aoddy.com/Project2
- Trac service supports SVN service too.
Softwares :
- enscript
- libapache2-mod-python
- python-docutils
- trac
- db4.3-util
- libapache2-svn
- subversion-tools
You can install software by
1 | $ sudo apt-get install enscript libapache2-mod-python python-docutils trac db4.3-util libapache2-svn subversion-tools |
Install & Configurations :
- Create SVN directory such as :
1
$ sudo mkdir /svn
- Set SVN directory to repository.
1
$ sudo svnadmin create /svn
- Create a user account so as to security policy.
1
$ sudo htpasswd 2 -cm /etc/apach2/dav_svn.passwd YOUR-ACCOUNT
- Create TRAC directory such as :
1
$ sudo mkdir /trac
- Change owner of TRAC directory to www-data :
1
$ sudo chown -R www-data:www-data /trac
- Create a configuration file of TRAC in apache
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
$ sudo vi /etc/apache2/site-available/trac.aoddy.com <VirtualHost * > ServerName trac.aoddy.com DocumentRoot /trac <Location /> SetHandler mod_python PythonInterpreter main_interpreter PythonOption TracEnvParentDir /var/lib/trac PythonOption TracUriRoot / </Location> <LocationMatch "/[^/]+/login"> AuthType Basic AuthName "Trac" AuthUserFile /etc/apache2/dav_svn.passwd Require valid-user </LocationMatch> Alias /svn /svn <Location /svn/> DAV svn SVNParentPath /svn SVNListParentPath On AuthType Basic AuthName "Subversion Repository" AuthUserFile /etc/apache2/dav_svn.passwd AuthzSVNAccessFile /etc/apache2/authz_svn.access Require valid-user </Location> ErrorLog /var/log/apache2/trac.aoddy.com/error.log CustomLog /var/log/apache2/trac.aoddy.com/access.log common </VirtualHost>
- Create a directory for keep error log.
1
$ sudo mkdir -p /var/log/apache2/trac.aoddy.com/
- Add this site into apache service.
1 2
$ sudo a2ensite trac.aoddy.com $ sudo /etc/init.d/apach2 restart
- Sometime you need to re-configure in this file, I recommend you should use these commands.
1 2 3
$ sudo a2dissite trac.aoddy.com $ sudo a2ensite trac.aoddy.com $ sudo /etc/init.d/apach2 restart
- Test by open an URL http://trac.aoddy.com/
Create SVN
You can use this script for create a SVN environment.
1 2 3 4 5 6 | #!/bin/bash
PROJECTNAME=$1
mkdir -p /tmp/${PROJECTNAME}/branches /tmp/${PROJECTNAME}/tags/ /tmp/${PROJECTNAME}/trunks
svnadmin create /svn/${PROJECTNAME}
svn import /tmp/${PROJECTNAME} file:///svn/${PROJECTNAME} -m "initial import"
sudo rm -rf /tmp/${PROJECTNAME} |
Don’t remember to change mode of this script to execute file and run this script by root permission.
Create TRAC
1 | $ sudo trac-admin /trac/YOUR-PROJECT-NAME initenv |
After you run this command you should find some question about your project
1 2 3 4 | the project name (YOUR-PROJECT-NAME) use the default database connection string (sqlite:db/trac.db) the path to svn repository (/svn/YOUR-PROJECT-NAME) use the default Trac templates directory (/usr/share/trac/templates) |
Change permission of this project so as to support apache service
1 | $ sudo chown -R www-data /trac/YOUR-PROJECT-NAME |
Woowww, you should find your new project on trac service at http://trac.aoddy.com/YOUR-PROJECT-NAME
Nice to see this Blog
um, trying to follow your guide. not working well. on step 9 the restart fails. I have tried this several times but to no avail. dang.