Installation and Configuration of Trac

APRICOT 2008, Taipei, Taiwan
February, 2008

These instructions are based upon a guide created by Luis Soares, but with considerable changes. The original guide is available here:
This installation allows for the following: Let's now do the installation of the trac system. For trac to work we will require python and a number of other packages. Then we'll have to create a trac environment for each repository we want trac to serve. Your instructor will describe what you are doing in more detail in class. This guide is available as text at:

$ sudo apt-get install trac libapache2-svn libapache2-mod-python libapache2-mod-python-doc python-setuptools
$ sudo mkdir /var/lib/trac
$ sudo chown -R www-data:www-data /var/lib/trac
$ sudo ln -s /var/lib/trac/ /trac

Now to add your trac site as a virtual site in Apache:

$ sudo vi /etc/apache2/sites-available/trac

In this file add the following:

        SetHandler mod_python
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnvParentDir /var/lib/trac
        PythonOption TracEnv /trac/apricot
        PythonOption TracUriRoot /trac/apricot
        SetEnv PYTHON_EGG_CACHE /trac/apricot/python-eggs

Now we enable the new virtual site:

$ sudo a2ensite trac

$ sudo /etc/init.d/apache2 reload

Next, we must initialize the trac project using the trac-admin facility. You will be asked several questions with lots of explanatory text. Here are the answers for each prompt you will see. If it says "[ENTER]", then just press ENTER and continue:

$ sudo trac-admin /trac/apricot initenv

Project Name [My Project]> WHATEVER YOU WANT
Database connection string [sqlite:db/trac.db]> [ENTER]
Repository type [svn]> [ENTER]
Path to repository [/path/to/repos]> [ENTER]
Templates directory [/usr/share/trac/templates]> [ENTER]

Now you will see quite a bit of text on your screen detailing items as your new trac project is created. Once this is done we have several more things to do to fix permissions again and enable the changes:

$ sudo chown -R www-data:www-data /var/lib/trac
$ sudo apache2ctl restart

Now to install some customization features for trac in the form of trac plug-ins:

$ sudo easy_install

$ sudo easy_install

$ sudo easy_install

Now we must edit the main trac configuration file with a number of items. For this we recommend that you view the file in a web browser at http://noc/worksop/presos/trac/trac.ini while completing this section.


Below are the items you need to add or change in your default trac.ini file. To edit this file do:

$ sudo vi /trac/apricot/conf/trac.ini

The first 2 items (account-manager and components) can go at the top of the file starting on line 3:

password_file = /trac/apricot/.htpasswd
password_format = htpasswd
password_store = HtPasswdStore

acct_mgr.* = enabled
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.accountmanager = enabled
acct_mgr.db.sessionstore = enabled
acct_mgr.htfile.htpasswdstore = enabled
acct_mgr.web_ui.accountmodule = enabled
acct_mgr.web_ui.loginmodule = enabled
acct_mgr.web_ui.registrationmodule = enabled
trac.web.auth.loginmodule = disabled
webadmin.* = enabled
azcalendar.* = enabled

The following three sections (header_logo, notification, project) replace what is in your trac.ini file. You can find the file "apricot-2008.jpg" here:


alt = APRICOT 2008 Net Mgmnt Workshop 
height = 143 
link = 
src = site/apricot-2008.jpg
width = 269 

always_notify_owner = true
always_notify_reporter = false
always_notify_updater = true
mime_encoding = base64
smtp_always_bcc = admin@localhost
smtp_always_cc = 
smtp_default_domain = 
smtp_enabled = true
smtp_from = apricot2008localhost
smtp_password = 
smtp_port = 25
smtp_replyto = apricot2008localhost
smtp_server = localhost
smtp_subject_prefix = __default__
smtp_user = 
use_public_cc = false
use_short_addr = false
use_tls = false

descr = APRICOT 2008 Network Management Workshop 
footer = APRICOT 2008, Taipei, Taiwan<br><a href="mailto:admin@localhost">admin@localhost</a>
icon = common/favicon.ico
name = APRICOT 2008, Taiwan 
url =

Note: Some items are not strictly necessary, and a couple will not work as we are currently configured, but won't cause problems either. The file apricot-2008.jpg file in http://noc/workshop/presos/trac/site/apricot-2008.jpg. This goes in /trac/apricot/htdocs on your machine.

Once all this is done you have just a few more steps. First we must configure the trac user environment. We'll set up a user called "apricot" that is an authenticated user, and a user called "admin" that will be a trac-admin user. Finally, all other users who view the project will be anonymous users. We will restrict their view of the project to be read-only. To do all this do (using cut and paste from your web browser would be a good idea below):

$ sudo trac-admin /trac/apricot permission remove anonymous CAL_ADMIN

$ sudo trac-admin /trac/apricot permission add authenticated CAL_ADMIN

$ sudo trac-admin /trac/apricot permission add apricot authenticated

$ sudo trac-admin /trac/apricot permission add admin TRAC_ADMIN

Now we need to be sure that Apache has access to all the trac files using the user/group of www-data:

$ sudo chown -R www-data:www-data /trac/*

$ sudo apache2ctl restart

Last, but not least, you must actually create the users "admin" and "apricot" and give them passwords:

$ sudo htpasswd -c /trac/apricot/.htpasswd admin      [use any password]

$ sudo htpasswd /trac/apricot/.htpasswd apricot         [use workshop password]

$ sudo trac-admin /trac/apricot upgrade

At this point you are done setting up trac. You can now look at the result of your work by going to:


By default you are seeing your trac project as an anonymous user. You
can log in as "apricot" to see how things look as an authenticated
user and then as "admin" to see things as a trac-admin user.