Installing Trac on CentOS

Posted by Jerzy Seweryn on
Installing Trac on CentOS


1. Before you do anything, go ahead and install subversion

2. Install the python easy install tool:

$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ sudo python ez_setup.py

3. Install Trac :

$ sudo easy_install Trac

4. Install mod_python :

$ sudo yum install mod_python python-devel

5. Create a new Trac project :

$ sudo trac-admin /var/www/trac/my_project initenv MyProjectName sqlite:db/trac.db svn /var/lib/subversion/repositories/my_project/


Obviously adjust the paths, project name etc according to your setup.

if you get this error :

ExtractionError: Can't extract file(s) to egg cache
 
The following error occurred while trying to extract file(s) to the Python egg
cache:
 
[Errno 13] Permission denied: '/root/.python-eggs'
 
The Python egg cache directory is currently set to:
 
 /root/.python-eggs
 
Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.


Then running this seems to fix it (courtesy of the trac-users mailing list ):

$ sudo easy_install -Z  Genshi==0.5

6. Setup a password file for authentication :

$ sudo htpasswd /var/www/trac/my_project/conf/passwords my_new_user

7. Install a couple of useful plugins (you can skip this step if you want a default trac installation) :

$ sudo easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk
$ sudo easy_install http://trac-hacks.org/svn/growlplugin/0.11/
$ sudo easy_install http://svn.recurser.com/ganttcalendar/trunk/
$ sudo easy_install http://trac-hacks.org/svn/datefieldplugin/0.11/
$ sudo easy_install http://trac-hacks.org/svn/breadcrumbsnavplugin/0.11


Add the following entries to your /var/www/trac/my_project/conf/trac.ini file to setup the various plugins :

[components]
acct_mgr.* = enabled
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.web_ui.accountmodule = enabled
acct_mgr.web_ui.loginmodule = enabled
acct_mgr.web_ui.registrationmodule = disabled
datefield.filter.datefieldmodule = enabled
ganttcalendar.ticketcalendar.ticketcalendarplugin = enabled
ganttcalendar.ticketgantt.ticketganttchartplugin = enabled
growl.notifier.* = enabled
growl.web_ui.growlpreferencepanel = enabled
trac.web.auth.loginmodule = disabled
 
[account-manager]
password_file = /var/www/trac/my_project/conf/passwords
password_store = HtPasswdStore
 
[growl]
sources = wiki, ticket, attachment, bitten
hosts =
userprefs = true
 
[datefield]
format = ymd
separator = /
 
[ticket-custom]
complete = select
complete.label = % Complete
complete.options = 0|5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90|95|100
complete.order = 3
due_assign = text
due_assign.label = Start (YYYY/MM/DD)
due_assign.order = 1
due_assign.date = true
due_assign.date_empty = true
due_close = text
due_close.label = End (YYYY/MM/DD)
due_close.order = 2
due_close.date = true
due_close.date_empty = true


Also, make sure ‘default_charset=UTF-8’ is present under the [trac] section (add it if it’s not).

8. Make your new user an administrator :

$ trac-admin /var/www/trac/my_project permission add my_new_user TRAC_ADMIN

9. Create a config file for Apache similar to the following :

NameVirtualHost *:9091
 
<VirtualHost *:9091>
 
    DocumentRoot /var/www/trac/my_project
    ServerName my_server_name
    ErrorLog logs/trac_error_log
    CustomLog logs/trac_access_log common
 
    <Directory "/var/www/trac/my_project">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
 
    <Location />
        SetEnv PYTHON_EGG_CACHE /usr/share/trac/plugin-cache
        SetHandler mod_python
        PythonInterpreter main_interpreter
        PythonHandler trac.web.modpython_frontend
        PythonOption TracEnv /var/www/trac/my_project
        PythonOption TracUriRoot /
    </Location>
 
</VirtualHost>

10. Restart Apache:

$ sudo /etc/init.d/httpd restart