Edgewall Software

Trac on Red Hat Enterprise Linux 4

WARNING: up2date command installs Trac 0.10… These instructions are valid for both 0.9 and 0.10 WARNING: Trac .10 will not function on RHEL x86_64 due to ClearSilver dependencies. Consider .11 instead.

UPDATE: 31-May-2007 I have just installed Trac 0.10.4 on Centos 4.4 (x86_64) using ClearSilver clearsilver-0.10.4-2.el4.rf rpm and it worked for me.

(Or TracOnRhel4WithoutYum)

Installing Trac Software and Dependencies

Installing Trac On Red Hat Enterprise Linux 4 (or rebuilds like CentOS4 or ScientificLinux4) is easy with the RPMforge packages from Dag and Dries. If you are not familiar with using these packages, you probably want to read http://rpmforge.net/user/faq/ first. If you are using Red Hat's up2date, you will need to download the rpmforge-release at http://rpmforge.net/user/packages/rpmforge-release/ and add the following lines to your /etc/sysconfig/rhn/sources file:

# Name: RPMforge RPM Repository for Red Hat Enterprise 4 - i386
yum rpmforge http://apt.sw.be/redhat/el4/en/i386/dag/
NOTE: The above is not meant to be executed on the command line. It is to be added to your /etc/sysconfig/rhn/sources file — as it states in the paragraph above. This was reported as broken — it is not. Please read carefully before you report things are broken — it confuses and deters people trying to follow the instructions

SELinux note: Please read TracWithSeLinux if you're using SELinux on RHEL4. Basically the default SELinux configuration only allows Apache to read certain directories, so you may need to add trac to the Apache context (man chcon) or turn off SELinux (man setenforce). For more information on SELinux, see http://fedora.redhat.com/docs/selinux-faq/. To turn off SELinux edit the /etc/selinux/config file and set SELINUX=disabled

After configuring up2date to use the RPMforge repository, run the following command in a terminal window:

  $ up2date --nosig -i trac

up2date will take care of all dependencies on which the Trac package depends (including clearsilver, guile, neon, perl-URI, python-clearsilver, python-sqlite, sqlite, subversion, and swig packages) and will fetch and install them for you automatically. For a full list of what it requires, see the RPM spec file at http://dag.wieers.com/packages/trac/trac.spec

Configure Subversion

Before we can create a new trac environment we must first have a working subversion repository if we are going to get the full use out of trac. Create a subversion repository if you don't already have one, for example in /opt/subversion/repos:

 $ mkdir -p /opt/subversion/repos
 $ svnadmin create  --fs-type fsfs /opt/subversion/repos

Next you need to decide where to store your trac project and create the directory, for example in the new directory /opt/trac/projectA:

 $ mkdir -p  /opt/trac

Creating an Environment

A new Trac environment is created using trac-admin:

$ trac-admin /opt/trac/projectA initenv

Trac will first ask a few questions about your environment in order to initalize and prepare the project database.

Please enter the name of your project. This name will be used in page titles and descriptions.

Project Name [My Project]> projectA

Please specify the connection string for the database to use. By default, a local SQLite database is created in the environment directory. It is also possible to use an already existing PostgreSQL database (check the Trac documentation for the exact connection string syntax).

Database connection string [sqlite:db/trac.db]> ''Enter to accept Default''

Please specify the absolute path to the project Subversion repository. Repository must be local, and trac-admin requires read+write permission to initialize the Trac database.

Path to repository [/var/svn/test]> /opt/subversion/repos

Please enter location of Trac page templates. Default is the location of the site-wide templates installed with Trac.

Templates directory [/usr/share/trac/templates]> ''Enter to accept Default'' 

Note: The web server user will require file system write permission to the environment directory and all the files inside. Please remember to set the appropriate permissions. The same applies to the Subversion repository Trac is eventually using, although Trac will only require read access as long as you're not using the BDB file system.

Directory Structure of Trac Environment

An environment directory will usually consist of the following files and directories:

  • README - Brief description of the environment.
  • VERSION - Contains the environment version identifier.
  • attachments - Attachments to wiki pages and tickets are stored here.
  • conf
    • trac.ini - Main configuration file. See TracIni.
  • db
    • trac.db - The SQLite database (if you're using SQLite).
  • plugins - Environment-specific plugins (Python eggs)
  • templates - Custom environment-specific templates.
    • site_css.cs - Custom CSS rules.
    • site_footer.cs - Custom page footer.
    • site_header.cs - Custom page header.
  • wiki-macros - Environment-specific Wiki macros.

Note: don't confuse a Trac environment directory with the Source Code Repository directory. It happens that the above structure is loosely modelled after the Subversion repository directory structure, but they are not and must not be located at the same place.

Apache Configuration

In this example we are using mod_python to run the trac front end given its speed advantages over cgi and fastcgi. But first we need to install mod_python:

$ up2date -i mod_python

Next, you need to edit the file /etc/httpd/conf.d/trac.conf to point to your new project environment, as in this example (using mod_python):

 <Location /projectA>
   SetHandler mod_python
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /opt/trac/projectA
   PythonOption TracUriRoot /projectA
 </Location>
 <Location "/projectA/login">
   AuthType Basic
   AuthName "trac"
   AuthUserFile /opt/trac/projectA.htpasswd
   Require valid-user
 </Location>

The example above assumes you have a trac project environment setup in /opt/trac/projectA/ directory and a htpasswd file in /opt/trac/projectA.htpasswd for authentication purposes (see also wiki:TracModPython). To create a new user password file use the following command (the -c option is given only the first time to create the file):

htpasswd -c /opt/trac/projectA.htpasswd username

We also need to give the apache user ownership of the trac environment and subversion repository

 $ chown -R root:webserv /opt/trac
 $ chown -R root:webserv /opt/subversion/repos

Permission Denied Errors

If you are getting a permission denied error saying that trac requires read _and_ write access to the project database file, you might have an SELinux environment. If SELinux is enabled, then you will have to run the following command as root.

 $ chcon -R system_u:object_r:httpd_sys_script_rw_t /opt/trac
 $ chcon -R system_u:object_r:httpd_sys_script_rw_t /opt/subversion/repos

If you aren't running SELinux, one possibility is apache needs ownership:

 $ chown -R webserv:webserv /opt/trac
 $ chown -R webserv:webserv /opt/subversion/repos

(On CentOS installations, webserv should be replaced with apache)

You will need to restart apache after editing trac.conf:

  $ /sbin/service httpd restart

Verify your Trac installation by pointing your browser at the correct URL for your Trac server,.

If you're installing any trac plugins, keep in mind that RHEL4 ships with Python 2.3. You can also find a python-setuptools rpm at http://install.linux.ncsu.edu/pub/yum/CLS/CLSTools.EL4/repodata/index.html

Note on centosplus

For those who have upgraded to PHP5, Trac might not work when used with mod_python.

Last line of stack call will be

  File "/var/tmp/python-sqlite-root//usr/lib/python2.3/site-packages/sqlite/main.py", line 244, in execute
DatabaseError: unsupported file format

This is because php has an embedded implementation of SQLite, enabled by default, and much more recent than the one used in mod_python. In that case, you'll have to disable SQLite support in PHP5 by editing /etc/php.d/pdo_sqlite.ini and commenting (#) the extension=pdo_sqlite.so line.

Please note this is a workaround, wich disable SQLite support in PHP5. If you're planning to use it for other developpement located on the same server, your should use instead the tracd install method .

Last modified 8 years ago Last modified on Jan 19, 2009, 3:05:46 PM