Trac is written in the Python programming language and needs a database, SQLite, PostgreSQL, or MySQL. For HTML rendering, Trac uses the Genshi templating system.
Installing trac 11.6 is complicated but easy, even with apache 2.2 (httpd)
There's some slight differences if you want to install the newest version .12 (and module/plugin compatibility?)
Trac 0.12 requires Python 2.5 or 2.6 (if you're using Centos 5 and Python 2.4 then it requires funny workarounds which may include installing a parallel Python 2.6 without breaking Yum) http://chrislea.com/2009/09/09/easy-python-2-6-django-on-centos-5/
Trac 0.12 requires Genshi v0.6 or later.
Tickets and ticket comments can now be deleted (requires enabling an optional component)
PREPARATION STEP: Having a web server installed!
Prerequisite Web Server
Centos Web Server HTTPD
Centos uses "yum" to install software packages, Debian uses "apt"
will find if your system already has httpd (or the http daemon)
yum install httpd yum install mod_ssl
this allows apache (httpd) work with OpenSSL yum install httpd-manual //if you want the manual
if you want to ensure you have the newest security updates
Debian/Ubuntu Web Server Apache
sudo apt-get install apache2 libapache2-mod-python
sudo apt-get install libapache2-mod-python-doc //if you want the manual
VERIFY YOUR APACHE IS OK
http://127.0.0.1 (or your ip address)
(ALWAYS watch out for firewalls! iptables -L -n --line-numbers -v)
BASIC HTTPD / APACHE CONFIGURATION
BEFORE making changes ALWAYS to back things up...
cd /etc/httpd/conf/ cd /etc/apache2/sites-available/default/ //DEBIAN/UBUNTU cp httpd.conf httpd.conf.bak nano /etc/httpd/conf/httpd.conf # least amount of info given out increase security ServerTokens Prod ServerRoot "/etc/httpd" PidFile run/httpd.pid Timeout 120 # Lower from 120 to 60 if you're worried about Denial of Service KeepAlive Off MaxKeepAliveRequests 100 KeepAliveTimeout 15 #Listen 80 # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) Listen 220.127.116.11:80 User apache Group apache ### Section 2 UseCanonicalName Off DocumentRoot "/var/www/html" <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
chown -R root:root /usr/sbin/httpd //ensure only root can run apache chown -R root:root /usr/conf/httpd.conf //ensure only root can modify apache
NOTE that there's already a Include conf.d/*.conf to load any /etc/httpd/conf.d files
After any apache config file changes it's best to restart & reload
/etc/init.d/httpd restart /etc/init.d/httpd reload service httpd reload //load the new configuration service httpd restart //(re)start apache (the http daemon) chkconfig --level 235 httpd on //ensure that apache starts at bootup (run levels 2,3,5) # ServerName
INSTALLING PYTHON, SQLLITE, GENSHII, TRAC
Installing trac on debian/ubuntu is pretty easy, unfortunately for Centos/Red Hat it's a lot more complicated...
# http://trac.edgewall.org/wiki/TracInstall # First ensure you have python >= 2.4 # may require sudo yum install -y which wget which python //will tell you if it's already installed, otherwise... yum install python //unfortunately for Centos 5.5 it's python 2.4.3 yum install mod_python //the module that allows apache to work with python yum install python-devel //required for the eventual pysqlite workaround # http://pypi.python.org/pypi/setuptools # http://peak.telecommunity.com/DevCenter/setuptools # http://pypi.python.org/pypi/setuptools#files # for newest version (below) setuptools-0.6c11, fast way to use python to install it... wget http://peak.telecommunity.com/dist/ez_setup.py $ sudo python ez_setup.py #run the easy_install app which isnstalls required dependencies + trac # sudo easy_install Trac //this would install the .11 version of Trac # Centos 5.5's python 2.4.3 needs some work to get the correct pySQLlite which python /usr/bin/python //will indicate python version, Control + D to exit wget http://pysqlite.googlecode.com/files/pysqlite-2.6.0.tar.gz tar -xzvf pysqlite-2.6.0.tar.gz cd pysqlite-2.6.0 python setup.py build_static install # error: Python.h: No such file or directory (you need yum install python-devel ) # Trac 0.12 requires Genshi v0.6 or later. sudo easy_install Genshi sudo easy_install Trac==0.12 # mkdir -p /trac-root/projects/trac //better to use the standard directories mkdir -p /var/www/html/trac (this makes all of the directories at once) trac-admin trac-admin - The Trac Administration Console 0.12 # if you use trac-admin project then use quit or exit interactive trac # create a new project called test trac-admin /var/www/html/trac/test initenv Project Name: test Database: hit enter for default SVN: hit enter for default (no svn usage) Path to Repository: enter for default (no svn usage) ... (bunch of stuff created) Project environment for 'test' created. You may now configure the environment by editing the file: /var/www/html/trac/test/conf/trac.ini
CONGRATULATIONS, YOU HAVE TRAC INSTALLED But not quite configured...
FINALLY, THE TRAC USERS SPECIFIC "VIRTUAL HOST" SECTION:
ENSURE APACHE CAN ACCESS TRAC FILES chown -R apache:apache trac //note that ubuntu user = www-data
TEST USING TRACD BUILT IN WEB SERVER
tracd -p 80 /var/www/html/trac/test & Server starting in PID 2160. Serving on 0.0.0.0:80 view at http://127.0.0.1:80/
NOTE if you forget the & to run it in the background that you may have to kill the session
- HTPASSWD AND APACHE AUTHENTICATION
(for security keep HTPASSWD file above your document root, DocumentRoot "/var/www/html" )
htpasswd -c /var/www/projects.password USERNAME // new user and new file! # ENSURE the apache user (or www-data) has read access to it! chgrp apache projects.password chmod 740 projects.password ls -ahl htpasswd /var/www/projects.password email@example.com
add another user cat /var/www/projects.password see user list
trac-admin /var/www/html/trac/test permission add USERNAME WIKI_ADMIN trac-admin /var/www/html/trac/test permission list
nano /etc/httpd/conf.d/trac.conf <Location /trac> SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir /var/www/trac PythonOption TracUriRoot /trac </Location> <VirtualHost *:80> <Location /trac> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir /var/www/html/trac PythonOption TracUriRoot /trac </Location> # for a trac installation controlling multiple projects (with the same login info) <LocationMatch "/trac/[^/]+/login"> AuthType Basic AuthName "Trac" AuthUserFile /var/www/projects.password Require valid-user </LocationMatch>
<Location /trac> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir /trac-root/projects/trac PythonOption TracUriRoot /trac </Location> </VirtualHost> http://127.0.0.1/trac //or http://domain.com/trac
If you get this error you may not have setup AUTHENTICATION, see above steps Trac Error Authentication information not available. Please refer to the installation documentation.
the following error has to do with access to Python .eggs The server encountered an internal error or misconfiguration and was unable to complete your request.
/var/log/httpd/error_log PythonHandler trac.web.modpython_frontend: ImportError: No module named trac
Compressed python eggs like Genshi are normally extracted into a directory named .python-eggs in the users home directory. Since apache's home usually is not writable an alternate egg cache directory can be specified like this:
PythonOption PYTHON_EGG_CACHE /var/trac/myprojects/egg-cache
ANOTHER SOLUTION is to reinstall / upgrade trac
easy_install -U Trac==0.12 Using /usr/lib/python2.4/site-packages/Trac-0.12-py2.4.egg
Now we can see where the .egg file is?
THE OLD WAY
/etc/httpd/conf/httpd.conf (or debian/ubuntu /etc/apache/sites-available/default) below <VirtualHost *:80> <Location /trac> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir /trac-root/projects/trac PythonOption TracUriRoot /trac </Location> # for a trac installation controlling multiple projects (with the same login info) <LocationMatch "/trac/[^/]+/login"> AuthType Basic AuthName "Trac" AuthUserFile /trac-root/projects.password Require valid-user </LocationMatch> # for only one project <Location "/trac/login"> AuthType Basic AuthName "Trac" AuthUserFile /somewhere/trac.htpasswd Require valid-user </Location>
NOTE: if you force all users to authenticate via apache, e.g.
<LocationMatch "/trac"> AuthType Basic AuthName "Please Authenticate" AuthUserFile /trac-root/projects.password Require valid-user </LocationMatch>
Then they won't notice the silly default "WIKI_VIEW privileges" aren't given to anonymous users and they'll immediately see the wikistart page.
TracError: The user apache requires read and write permissions to the database file /trac-root/projects/trac/projectname/db/trac.db and the directory
don't forget! chown -R apache /trac-root/projects/trac //note that ubuntu user = www-data
migrating projects is easily begun by copying the project directory into the new server...
BUT you'll have to modify permissions (for the apache user to have read/write access)...
AND you'll have to clean up any absolute links, or SVN connections (if you've a different or removed the repository entirely then set the repository_dir to blank...), also, hopefully your project url is a relative path (and NOT an absolute url!)
nano trac.ini [project] url = /trac/projectname ... [trac] repository_dir =
TO install new or upgrade plugins see the next documentation: trac-wiki-install-plugins