Trac is an issue/bug tracking system for software development projects. It has a built in wiki for documentation and a broseable interface to Subversion or other version control systems. All interaction is done with a a web browser which makes it easy and fast. It is programmed in Python.
We will be installing Trac on CentOS 5. There are a few things you will need to know about the following install. This install will be using Trac's built in web server instead of using another web server to serve the content. It will use Sqlite as the back end database and Subversion for the version control system. Note that Trac has to be installed on the same server as Subversion so it can read the repositories.
All versions in the examples where the versions of the software at the time. You will have to substitute the latest version numbers in for your install. Do all of the installs below as the root user.
Before starting the install let's make sure we have the packages we need to get Trac working. In CentOS 5 you will need the packages python, sqlite, and python-sqlite. To install them just issue the yum command and package names. If they are already installed yum will just tell you it's already installed. No big deal.
yum install sqlite python-sqlite python
To make installing Trac much easier we are going to use a Python program called setuptools. Setuptools let's you download, build, install, upgrade, and uninstall Python packages in a very easy manner. Setup tools includes a program called easy_install. This is what we are going to use to install Trac.
Let's get and install setuptools.
Now we can install trac using easyinstall
Now that Trac is installed we can add some helpful Trac plugins. Plugins are optional and don't need to be installed for Trac to work. Plugins just help extend the features of Trac from the base install.
Install the trac plugin "customfieldadminplugin" for adding custom fields in the db via the webadmin.
Install trac plugin "iniadminplugin" to give the admin acces to edit the ini file.
Install trac plugin "tracwysiwygplugin" to give wiki editor wisiwyg properties.
Now that Trac is installed we can create some Trac sites. You can have as many Trac sites as you like. Make sure you have any Subversion repositories setup now before you make any Trac sites. You could go back in later and add them but it's just easy to do during setup.
Lets make a dir for all the Trac sites to live in. Each site will get it's own dir with all of it's own files. A nice clean setup. I'm going to install the Trac sites to a dir called /disk01/trac.
Let's create a new Trac environment for the project. We will use SITE1 as the example site name.
trac-admin /disk01/trac/SITE1 initenv
Follow the prompts and answer the questions for the site. The example of the answers are below. What you call the project name is what that sitename will be.
Project Name [My Project]> SITE1 Database connection string [sqlite:db/trac.db]> [Enter] Repository type [svn]> svn Path to repository [/path/to/repos]> /disk01/svn/SITE1
Let's add a user so they have an account on the Trac site. The username can be anything. I'll use john in the example. The realm is the name of the Trac site above. The password is an MD5 sum of the tuple username:realm:password. I'll use blahblah as the password in the example.
echo -e "john:SITE1:blahblah\c" | md5sum | cut -d ' ' -f 1
The output if the line above will give you the MD5 sum: 452079cd32f63d0c405a708d5cb0d264. That is our password. We take that password and put it in the tuple line to get john:SITE1:452079cd32f63d0c405a708d5cb0d264. This is the line we will need to put in the /disk01/trac/SITE1/conf/.htpasswd file in the Trac sites configuration directory. Create the file with your favorite editor and put in the line and save it. You can make as many accounts as you want this way. An example file with a few accounts are below.
Now we need to make some changes to the Trac.ini file. This file has the config settings for the Trac site. Edit the file /disk01/trac/SITE1/conf/trac.ini. Add the following lines in each section of the file. If the lines exist then change the value to match the line below. These are just settings that I like to change you can change whatever you like. The [components] section is needed for plugins. Every time you add a plugin you have to enable it for each site. These will enable the plugins we installed. Webadmin plugin is part of the .11 release of Trac. You still have to enable it though.
[attachment] max_size = 10262144 [ticket] restrict_owner = true [components] webadmin.* = enabled customfieldadmin.* = enabled iniadmin.iniadmin.iniadminplugin = enabled tracwysiwyg.* = enabled
Now we can make the admin for the Trac site. The admin username has to be a user in the /disk01/trac/SITE1/conf/.htpasswd file. So lets use john.
trac-admin /disk01/trac/SITE1 permission add john TRAC_ADMIN
Now that we have the new site created we need to add a line to the Trac startup. The line will be the Trac realm name used when making the line for the .htpasswd file. Tracd is the daemon that runs the Trac site. We will run Trac out of /etc/rc.local. In there you can put a line that looks like the following.
tracd -d -b 192.168.0.2 -e /disk01/trac/ \ --auth=SITE1,/disk01/trac/SITE1/conf/.htpasswd,SITE1 \ --auth=SITE2,/disk01/trac/SITE2/conf/.htpasswd,SITE2
This is the line used to start the Trac built in web server. It will start on port 80 by default and you can specify the ip for it to bind to if need be. If there is already a web server running on that machine just make an interface alias and add another ip and bind Trac to it. You can just copy and paste the start line above to the command line and execute it to see if it works. Just make sure you remove any sites you have not made already before you run it. If it works then throw that line in /etc/rc.local and it will start on boot.
After you start the Tracd deamon you can browse to your new Trac site with a web browser. It's just the hosts name with the name of the Trac site like for example http://trac.pantz.org/SITE1.
Keep adding as many sites as you like. Just keep making Trac environments and setting them up the way we just did. To backup the Trac sites just backup the directories you have the Trac sites in. For this example it would be /disk01/trac. It's that easy.