I have a trac instance for each subversion repo on my dreamhost account.
After a few years, I've accumulated many repos. There are too many to maintain by hand, so I've settled on a standardized deployment and use scipts to manage them.
Everything is organized as such:
~/webroot/
main web directory~/webroot/svn.example.com
domain for subversion/trac~/webroot/svn.example.com/{PROJECT}
path for project webroot~/webroot/svn.example.com/{PROJECT}/svn
path configured in control panel as repo url~/webroot/svn.example.com/{PROJECT}/trac
trac url for repo~/svn/
dreamhosts's subversion directory~/svn_trac/
where I have trac instances~/svn_trac/{PROJECT}
trac repo shares the same name as subversion repo~/svn_trac/trac-venv
python virtualenv for trac~/svn_trac/trac-deploy
exported trac files~/svn_trac/trac-MANAGEMENT
management tools
trac
is installed into a virtualenv that is used by all installations. my scripts deploy htaccess files that use the dreamhost-managed subversion htpasswd files for access; they also use symlinks to share the "static" assets from a single project. Enrolling projects into the system only requires adding a line to a text file.
cd ~
mkdir svn_trac
cd svn_trac
virtualenv trac-venv
vi go_trac.sh
> source trac-venv/bin/activate
chmod 744 go_trac.sh
source go_trac.sh
we should see the prompt as (trac-venv)[user]$
make sure pip and easy_install are current
easy_install --upgrade pip
pip install --upgrade --force setuptools
then install trac
pip install trac
thankfully these are on the machine already. just copy them to the local env
cd ~/svn_trac/trac-venv/lib/python2.7/site-packages/
cp -R /usr/lib/python2.7/dist-packages/libsvn .
cp -R /usr/lib/python2.7/dist-packages/svn .
make sure we're using the right trac-admin
cd ~/svn_trac
which trac-admin
that should show our trac-env version, not the server
cd ~/svn_trac
trac-admin MyProject initenv
let's use one project to create the deployment files that all projects can use
we'll overwrite the ENV variables as needed
cd ~/svn_trac
trac-admin MyProject deploy trac-deploy
chmod +x trac-deploy/cgi-bin/trac.fcgi
cd ~/svn_trac
mkdir trac-MANAGEMENT
two files go in there:
trac_sites.txt
a listing of your projects. one per line.deploy.py
the script below
to deploy the sites:
cd ~/svn_trac/trac-MANAGEMENT
python deploy.py
The deploy
script manages everything in webroot/svn.example.com
it does the following for PROJECTNAME:
- creates a project directory
~/webroot/svn.example.com/PROJECTNAME
- install an htaccess
~/webroot/svn.example.com/PROJECTNAME/.htaccess
that references the subversion password file~/svn/PROJECTNAME.passwd
- install an index.html that points to
/svn
and/trac
- creates a
/trac
directory - installs a
/trac/.htaccess
file that handles pretty urls and fcgi - installs a
/trac/index.fcgi
file that points to the~/svn/PROJECTNAME
repo, exports your virtualenv's path, and executes the trac invocation script in~/svn_trac/trac-MANAGEMENT/cgi-bin
- installs a symlink on
/trac/chrome
to the~/svn_trac/trac-deploy/htdocs
folder
set the repo
repository_dir = /home/jvanasco/svn/APP
[components]
tracopt.versioncontrol.svn.svn_fs.* = enabled
[svn]
branches = trunk,branches/*
tags = tags/*