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:

[code lang="shell"]
$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ sudo python ez_setup.py
[/code]

3. Install Trac :

[code lang="shell"]
$ sudo easy_install Trac
[/code]

4. Install mod_python :
[code lang="shell"]
$ sudo yum install mod_python python-devel
[/code]


5. Create a new Trac project :
[code lang="shell"]
$ sudo trac-admin /var/www/trac/my_project initenv MyProjectName sqlite:db/trac.db svn /var/lib/subversion/repositories/my_project/
[/code]



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

if you get this error :
[code lang="shell"]
ExtractionError: Can't extract file(s) to egg cache
[/code]


The following error occurred while trying to extract file(s) to the Python egg
cache:
[code lang="shell"]
[Errno 13] Permission denied: '/root/.python-eggs'
[/code]


The Python egg cache directory is currently set to:
[code lang="shell"]
/root/.python-eggs
[/code]


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 ):
[code lang="shell"]
$ sudo easy_install -Z  Genshi==0.5
[/code]


6. Setup a password file for authentication :
[code lang="shell"]
$ sudo htpasswd /var/www/trac/my_project/conf/passwords my_new_user
[/code]


7. Install a couple of useful plugins (you can skip this step if you want a default trac installation) :
[code lang="shell"]
$ 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
[/code]



Add the following entries to your /var/www/trac/my_project/conf/trac.ini file to setup the various plugins :
[code lang="shell"]
[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
[/code]



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 :
[code lang="shell"]
$ trac-admin /var/www/trac/my_project permission add my_new_user TRAC_ADMIN
[/code]


9. Create a config file for Apache similar to the following :
[code lang="shell"]
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>
[/code]


10. Restart Apache:
[code lang="shell"]
$ sudo /etc/init.d/httpd restart

[/code]