Edgewall Software

Version 4 (modified by dlin.tw@…, 13 years ago) ( diff )

Installing Trac on ArchLinux for Multiple Projects using Mod_Python

ArchLinux is powered by a simple and lightweight package management system. It is release by rolling binary system. Keep update by command line pacman -Syu will get the most recent version.

In following steps, I set these variable for simply input

TROOT=/home/trac  # put the multiple trac project's db
SROOT=/home/svn   # put the multiple project subversion repositories
PRJ=project1      # put each project's name

install packages

install depend packages from binary

pacman -S mod_python python-pysqlite subversion

Download trac from binary

Trac is already on community repository, check /etc/pacman.conf, make sure uncomment the following.

# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/community

SUPFILES=(arch extra !unstable community !testing)

download and install it

pacman -S trac 

or, build trac from source

if want the newest version trac.

edit the /etc/abs/abs.conf, unmark the community

SUPFILES=(arch extra !unstable community !testing)
cd /var/abs/community/network/trac
vi PKGBUILD  # modify the version to the newest version
makepkg -g   # modify PKGBUILD with the correct md5 checksum
makepkg -c   # build binary package file, and clean up work files after build
sudo pacman -A *.pkg.tar.gz  # install it
sudo pacman -U *.pkg.tar.gz  # or, upgrade it, if already installed

configure mod_python and svn_dav

edit /etc/httpd/conf/httpd.conf, append following line

LoadModule python_module           modules/mod_python.so
LoadModule dav_svn_module          modules/mod_dav_svn.so
LoadModule authz_svn_module        modules/mod_authz_svn.so

use following line to restart apache, check /var/log/httpd/error.log, if failed

/etc/rc.d/httpd restart

Tips: you can check it by http://your_server_ip/server-info after following config

edit /etc/httpd/conf/httpd.conf, uncomment following line
Include /etc/httpd/conf/extra/httpd-info.conf

edit /etc/httpd/conf/extra/httpd-info.conf, modify the "Allow from" to your client ip address

setup subversion for each project

mkdir -p $SROOT/$PRJ
mkdir /tmp/$PRJ
mkdir /tmp/$PRJ/branches
mkdir /tmp/$PRJ/tags
mkdir /tmp/$PRJ/trunk
svnadmin create $SROOT/$PRJ
svn import /tmp/$PRJ file://$SROOT/$PRJ -m "initial import"
rm -rf /tmp/$PRJ
svn ls -v file://$SROOT/$PRJ   # check it

setup trac db for each project

mkdir -p $TROOT

setup by interactive questions

trac-admin $TROOT/$PRJ initenv 

or, by command line parameters

trac-admin $TROOT/$PRJ initenv $PRJ sqlite:db/trac.db svn $SROOT/$PRJ /usr/share/trac/templates

edit $TROOT/$PRJ/conf/trac.ini

link = http://your_server_ip/trac
log_type = file    <-- we need check log to figure out problems
url = http://your_server_ip/trac/project1  <-- change to $PRJ


create password file

htpasswd -c /home/trac/.htpasswd admin  # create 'admin' account
htpasswd /home/trac/.htpasswd new_user  # append a 'new_user' account

create access file

sample /home/svn/.svn.access

* = r

admin = rw

configure apache

chown -R nobody $SROOT $TROOT  # allow httpd's owner 'nobody' could read/write

edit /etc/httpd/conf/httpd.conf,  uncomment following line
Include /etc/httpd/conf/extra/httpd-vhosts.conf

edit /etc/httpd/conf/extra/httpd-vhosts.conf, append following lines
<VirtualHost *:80>
    ServerAdmin your_name@email.address
    DocumentRoot /home/trac/  # <- change to $TROOT
    ServerName your_server_ip
    ErrorLog /var/log/httpd/trac.error.log
    CustomLog /var/log/httpd/trac.access.log combined
    <Location />
        Order deny,allow
        Deny from all
        Allow from # <- allow local network only
    <Location /trac> #set up Trac handling
        Order deny,allow
        Deny from all
        Allow from # <- allow local network only
        AuthName "Trac Projects"
        AuthType Basic
        AuthUserFile /home/trac/.htpasswd # <- place to put password by htpasswd2
        Satisfy Any
        Require valid-user
        SetHandler mod_python
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnvParentDir /home/trac    # <-- change to $TROOT value
        PythonOption TracUriRoot /trac
    <Location /svn>
       DAV svn 
       SVNParentPath /home/svn/  # <- change to $SROOT
       AuthzSVNAccessFile /home/svn/.svn.access  # <- place to put access file
       AuthName "SVN Repo"
       AuthType Basic
       AuthUserFile /home/trac/.htpasswd # <- place to put password by htpasswd2
       Satisfy Any
       Require valid-user

/etc/rc.d/httpd restart 
# if failed, manual start up httpd by following command, and check the information
apachectl -k start

Now, you should be able to access Trac at http://you_server_ip/trac/$PRJ

access via https(optional)

via https will more safer, but it may be slower.

cd /etc/httpd/conf  # must change to this directory before doing the mod_ssl.txt
more mod_ssl.txt
  1. following the instructions in mod_ssl.txt to generate key files.
  2. Add the the lines of httpd-vhosts.conf to /etc/httpd/conf/extra/httpd-ssl.conf.
  3. uncomment the include /etc/httpd/conf/extra/httpd-ssl.conf in /etc/httpd/conf/httpd.conf
  4. restart apache by /etc/rc.d/httpd restart
Note: See TracWiki for help on using the wiki.