] >
Due to the popularity of my first guide, I decided to update it to reflect the new Trac and Subversion releases.
This guide was made primarily to help DreamHost customers setup Trac. However, the setup is generic enough, that with only little modification, this guide can be applied to any shared-hosting setup running the Apache webserver (or if you want to use cgi for some reason). To work, you will need access to shell, and have basic understanding of text editing in shell. Dreamhost provides python2.3, and easy subversion repository setup - so these are assumed to already be in place.
Also, because I do not like the login hack described on the DreamHost Trac Wiki, I have assumed that you will install one of the login plugins. However, if you have access to the Apache setup file and do not wish to use a login manager, you can use the account setup method outlined in the Trac wiki.
I found installing a local copy of python to be unnecessary, as the extra modules can be installed in the trac's lib path. To assure access to these libs, the PYTHONPATH environment variable must reference the aforementioned path.
Add this to ~/.bash_profile:
export PYTHONPATH="$HOME/packages/lib/python2.3/site-packages"
export LD_LIBRARY_PATH="$HOME/packages/lib"
export PATH="$HOME/packages/bin:$PATH"source ~/.bash_profileI recommend making a special directory for the install files and packages; this makes it easier to manage, and you can delete the entire directory of install files at the end. I used ~/packages and ~/install_files personally, and will be using them throughout these instructions - so if you want to use another directory, just replace all references.
cdmkdir install_filesmkdir packagesmkdir trac_sitescd ~/install_fileswget http://ftp.edgewall.com/pub/trac/trac-0.10.3.tar.gztar zxf trac-0.10.3.tar.gzcd trac-0.10.3python setup.py install --prefix=$HOME/packagescd ~/install_fileswget http://www.clearsilver.net/downloads/clearsilver-0.10.4.tar.gztar zxf clearsilver-0.10.4.tar.gzcd clearsilver-0.10.4sed -i "s@/usr/local/bin/python@/usr/bin/env python@g" \
scripts/document.py
PYTHON_SITE=`/home/{username}/packages/bin/python -c \
"import sys; print [path for path in sys.path if \
path.find('site-packages') != -1][0]"` \
./configure --with-python=/home/{username}/packages/bin/python \
--prefix=$HOME/packages \
--disable-ruby --disable-java --disable-apache --disable-csharp --disable-perlmakemake installcd ~/install_fileswget http://www.sqlite.org/sqlite-3.3.13.tar.gztar zxf sqlite-3.3.13.tar.gzcd sqlite-3.3.13./configure --prefix=$HOME/packagesmakemake installln -s $HOME/packages/bin/sqlite3 $HOME/packages/bin/sqlitecd ~/install_fileswget http://initd.org/pub/software/pysqlite/releases/2.3/2.3.3/pysqlite-2.3.3.tar.gztar zxf pysqlite-2.3.3.tar.gzcd pysqlite-2.3.3include_dirs = [] to include_dirs = ['$HOME/packages/include']library_dirs = [] to library_dirs = ['$HOME/packages/lib']python setup.py buildpython setup.py install --prefix=$HOME/packagescd ~/install_fileswget http://dl.sourceforge.net/sourceforge/swig/swig-1.3.31.tar.gztar zxf swig-1.3.31.tar.gzcd swig-1.3.31./configure --prefix=$HOME/packages --with-python=/usr/bin/pythonmakemake installcd ~/install_fileswget http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gztar zxf subversion-1.4.3.tar.gzcd subversion-1.4.3./configure PYTHON=/usr/bin/python --prefix=$HOME/packages \
--with-swig=$HOME/packages/bin/swig --without-berkeley-db \
--with-ssl --with-zlibmakemake installmake swig-pymake install-swig-pycd ~/packages/lib/python2.3/site-packagesecho $HOME/packages/lib/svn-python > subversion.pthln -s ~/packages/lib/svn-python/libsvnln -s ~/packages/lib/svn-python/svnpython -c "from svn import client" (No errors should result.)trac-admin $HOME/trac_sites/{your trac project id} initenv
("{your trac project id}" can be anything you like. Putting all your Trac environments in your trac_sites directory allows for simpler backup!)
You will be asked for
trac-admin $HOME/trac_sites/{your trac project id} will put you into interactive mode. You can issue a simple help at the prompt to see what you can do. There are lots of administrative actions in interactive mode that can make your life a little easier than it would be if you always had to go through the WebAdmin interface.
You should add at least one user with admin powers. To do this, in interactive mode:
permission add admins TRAC_ADMINpermission add {username} adminsexit (to quit interactive mode)During interactive mode, permission list should show the new users on the list.
cd ~/{my.domain.name}Make index.cgi (make sure to set the permissions so the webserver can read it - 775):
#!/bin/bash
export HOME="/home/{username}"
export TRAC_ENV="$HOME/trac_sites/{your trac project id}"
export PYTHONPATH="$HOME/packages/lib/python2.3/site-packages"
export PATH="$HOME/packages/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/packages/lib"
exec $HOME/packages/share/trac/cgi-bin/trac.cgiand index.fcgi (make sure to set the permissions so the webserver can read it - 775):
#!/bin/bash
export HOME="/home/{username}"
export TRAC_ENV="$HOME/trac_sites/{your trac project id}"
export PYTHONPATH="$HOME/packages/lib/python2.3/site-packages"
export PATH="$HOME/packages/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/packages/lib"
exec $HOME/packages/share/trac/cgi-bin/trac.fcgiThen set the default by editing .htaccess:
DirectoryIndex index.cgi
You can change this to index.fcgi once you have everything setup. (Fcgi is faster, but you won't notice changes until a day later.)This allows the common static files (images, CSS, javascript, etc) to be accessed directly, rather than mapping through the cgi script. (This makes Trac faster, while providing compatibility with the prettiness.)
cd ~/{domain name}mkdir chromeln -s $HOME/packages/share/trac/htdocs ./chrome/commonEdit .htaccess located in the {domain name} directory
DirectoryIndex index.cgi
Options ExecCGI FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.cgi/$1 [L]
</IfModule>
This will prefix any failed request with index.cgi (to run it through Trac).
This sets any links Trac generates to ignore the file generated from, and just start from the directory, rather than the file that processed the generation. (/blarg/foobar, instead of /blarg/index.cgi/foobar)
cd $HOME/packages/lib/python2.3/site-packages/trac/webcp api.py api.py.backup base_path = property(fget=lambda self: self.environ.get('SCRIPT_NAME', ''),
doc='The root path of the application')
base_path = property(fget=lambda self: os.path.dirname(self.environ.get('SCRIPT_NAME', '')),
doc='The root path of the application')We'll be using this to install the other plugins; so it is necessary to install this to follow my steps.
cd ~/install_fileswget http://peak.telecommunity.com/dist/ez_setup.pypython ez_setup.py --prefix=$HOME/packagescd ~/install_filessvn co http://svn.edgewall.com/repos/trac/sandbox/webadmin/cd webadminpython setup.py egg_infopython setup.py bdist_eggcd disteasy_install --prefix=$HOME/packages *.egg$HOME/trac_sites/{your trac project id}/conf/trac.ini and adding to the components section:
[components]
webadmin.* = enabledThis will make the htpasswd login method much more pleasing. New users can register on their own using the site, and they can change their passwords if necessary. This also allows login via form, rather than the HTTP authentication.
cd ~/install_filessvn co http://trac-hacks.org/svn/accountmanagerplugin/0.10 accountmanagerplugincd accountmanagerpluginpython setup.py bdist_eggcd disteasy_install --prefix=$HOME/packages *.egghtpasswd -c ~/trac_sites/trac.htpasswd {username}$HOME/trac_sites/{your trac project id}/conf/trac.ini and adding to the components section:
[components]
trac.web.auth.LoginModule = disabled
acct_mgr.* = enabled
[account-manager]
password_format = htpasswd
password_file = /home/{your username}/trac_sites/trac.htpasswdMakes more sense than the normal login method. However it does not support new user registration like AccountManager, rather, you are required to enter all users in manually using sqlite. Because of this, I use AccountManager instead.
cd ~/install_filessvn co http://trac-hacks.org/svn/dbauthplugin/0.10 dbauthplugincd dbauthpluginpython setup.py bdist_eggcd disteasy_install --prefix=$HOME/packages *.eggcd ../installcp dbauth.db ~/trac_siteschmod 775 ~/trac_sites/dbauth.dbsqlite ~/trac_sites/dbauth.dbINSERT INTO trac_users VALUES ('all', 'username', 'passwd', 'email@email.com');
INSERT INTO trac_permissions VALUES ('all', 'username', 'admins');
.quit$HOME/trac_sites/{your trac project id}/conf/trac.ini and adding to the components section:
[components]
trac.web.auth.* = disabled
dbauth.* = enabled
#trac.userdir.* = enabled # only if you want to use this
[central]
database = /home/{your username}/trac_sites/dbauth.db
envroot = /home/{your username}/trac_sites/{your trac project id}Adds the ability to configure trac.ini via a web interface.
cd ~/install_filessvn co http://trac-hacks.org/svn/iniadminplugin/trunk/ iniadmincd iniadminpython setup.py bdist_eggcd disteasy_install --prefix=$HOME/packages *.egg$HOME/trac_sites/{your trac project id}/conf/trac.ini and adding to the components section:
[components]
iniadmin.* = enabledAdds ability to add navigation elements to wiki pages.
cd ~/install_filessvn co http://svn.ipd.uni-karlsruhe.de/repos/javaparty/JP/trac/plugins/tracnav/cd tracnavpython setup.py bdist_eggcd disteasy_install --prefix=$HOME/packages *.egg$HOME/trac_sites/{your trac project id}/conf/trac.ini and adding to the components section:
[components]
tracnav.* = enabledNow that you have everything setup the way you want, you can go ahead and delete all those setup files, and switch to fast_cgi
Since you won't be using those setup files after you're done, if you don't want all those setup files to take up hard drive space, you can delete them.
cdrm -rf install_filesNOTE: If you are using DreamHost, make sure FCGI is enabled in the DreamHost control panel for the domain you're configuring.
Change .htaccess to direct to index.fcgi, rather than index.cgi:
DirectoryIndex index.fcgi
Options ExecCGI FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.fcgi/$1 [L]
</IfModule>
Just change the .htaccess DirectoryIndex to index.fcgi
DirectoryIndex index.fcgi