Published by nick on 26 Oct 2007 at 12:36 am
Installing Trac with subversion on Cent OS 5
Trac is a decent bug tracking software that is getting a lot of attention these days. It’s very simple to use, which I like. It includes subversion integration so that you can walk through your source code tree and view diffs from one version to another. Handy.
However, Trac’s installation process has a lot of room for improvement in the simplicity department. Here are the steps I went through to install trac on Cent OS 5. I captured them so that others may find it easier to get Trac up and running. Enjoy.
If these instructions work for you, please leave a comment! If they don’t, please leave a comment!
- Install python and it’s goodies.
- Use yum to install the base package:
yum install python - Install mod_python. This is so Apache can run the python scripts as a module:
yum install mod_python - Install MySQL-python so that python can interact with mysql
- Download and untar MySQL-python from http://sourceforge.net/projects/mysql-python
cd $mysqlpythonsourcedirpython setup.py build && python setup.py install
- Use yum to install the base package:
- Install some devel packages that are needed for compiling trac and svn integration:
yum install neon neon-devel python-devel swig - Install Clearsilver, a templating package that trac depends on.
- Download and untar clearsilver from http://www.clearsilver.net/downloads/
- Compile
cd $clearsilversourcedir; ./configure && make && make install
- Install trac!
- Download and untar trac from http://trac.edgewall.org/wiki/TracDownload
cd $tracsourcedir; python ./setup.py install- Initialize your first trac project:
trac-admin $pathtoyourtracproject initenv - Tell Apache about trac.. Add the following lines to your Apache configuration file:
<Location /> SetHandler mod_python PythonHandler trac.web.mod python_frontend PythonOption TracEnv $pathtoyourtracproject PythonOption TracUriRoot /trac/ </Location>
Finally, restart httpd and try it out by going to:
http://$yourhost/trac/
If it doesn’t work, check in your webserver error log for errors: tail -f /var/log/httpd/error_log
Again, please leave a comment so that you may help others with the same problems you have.
Daniel Skinner on 14 Dec 2007 at 12:38 pm #
The guide is working well for me so far. I have a problem with trac-admin however.
When running initenv it asks for the ‘Templates directory’. The default value is a windows path and I have no idea what it should be for CentOS. Any ideas?
nick on 14 Dec 2007 at 1:45 pm #
Daniel,
Happy to help.
You are running this line:
trac-admin $pathtoyourtracproject initenv
Are you running it literally? You are supposed to replace $pathtoyourproject with an empty directory that you create for where want to store your trac data.
I didn’t make that clear in the docs, I’ll update.
Daniel Skinner on 14 Dec 2007 at 4:35 pm #
It was clear enough to me, I did it right. It seemed like all the environment variables were Windows-like.
I think this is because I tried Trac’s easy_install method first and it messed it up.
I have started from a fresh CentOS install and am about to install svn/trac using your guide. I will keep you updated.
Daniel Skinner on 14 Dec 2007 at 4:52 pm #
Nick,
I got it working. Thanks for the help and the awesome guide, it was exactly what I was looking for.
Here is what I did (for anyone else):
- Fresh install of CentOS 5 (running as a virtual machine).
- Followed the CentOS 5 Perfect Setup Guide.
-
yum install subversion- Created a subversion repository with
svnadmin create- Followed this guide word for word (except for the Apache configuration, I needed a different solution).
- I also used parts of CentOS, Subversion How-To (setting up Apache and SVN) and Trac on Fedora Guide (setting up Apache and Trac).
I don’t think following the ‘Perfect Setup Guide’ is required at all - it’s just what I did.
Thanks
Daniel Skinner on 14 Dec 2007 at 5:53 pm #
I spoke to soon. This might be outside the focus of your guide but I’m stuck at the moment. I have set up Trac with apache and when I try to view Trac in a web browser I get the following:
Traceback (most recent call last):File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 406, in dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 206, in dispatch
req.hdf = HDFWrapper(loadpaths=chrome.get_all_templates_dirs())
File "/usr/lib/python2.4/site-packages/trac/web/clearsilver.py", line 135, in __init__
raise TracError, "ClearSilver not installed (%s)" % e
TracError: ClearSilver not installed (No module named neo_cgi)
Any ideas?
Daniel Skinner on 14 Dec 2007 at 5:58 pm #
Ok, again I was too hasty with the comment button!
Here is what I did to fix it:
wget http://dag.wieers.com/rpm/packages/clearsilver/clearsilver-0.10.4-1.el5.rf.i386.rpm
rpm -i clearsilver-0.10.4-1.el5.rf.i386.rpm
wget http://dag.wieers.com/rpm/packages/clearsilver/python-clearsilver-0.10.4-1.el5.rf.i386.rpm
rpm -i clearsilver-0.10.4-1.el5.rf.i386.rpm
Setup Subversion and Trac on CentOS 5 | Daniel Skinner: News and Articles on Web Development on 06 Jan 2008 at 10:19 am #
[…] Install Trac: Follow Nick’s guide with the alternative Clearsilver installation below. Skip the Apache Configuration […]
sushmi on 18 Jan 2008 at 4:31 am #
I installed trac with subversion+apache. During the execution of “trac-admin” for database string i gave “mysql://root:a@localhost:3306/trac”
since i used mysql database but during environment creation the following error occured.
Please enter location of Trac page templates.
Default is the location of the site-wide templates installed with Trac.
Templates directory [/usr/local/share/trac/templates]>
Creating and Initializing Project
Failed to create environment. No module named MySQLdb
Traceback (most recent call last):
File “/usr/local/lib/python2.4/site-packages/trac/scripts/admin.py”, line 613, in do_initenv
options=options)
File “/usr/local/lib/python2.4/site-packages/trac/env.py”, line 145, in __init__
self.create(options)
File “/usr/local/lib/python2.4/site-packages/trac/env.py”, line 250, in create
DatabaseManager(self).init_db()
File “/usr/local/lib/python2.4/site-packages/trac/db/api.py”, line 70, in init_db
connector.init_db(**args)
File “/usr/local/lib/python2.4/site-packages/trac/db/mysql_backend.py”, line 44, in init_db
cnx = self.get_connection(path, user, password, host, port, params)
File “/usr/local/lib/python2.4/site-packages/trac/db/mysql_backend.py”, line 40, in get_connection
return MySQLConnection(path, user, password, host, port, params)
File “/usr/local/lib/python2.4/site-packages/trac/db/mysql_backend.py”, line 132, in __init__
import MySQLdb
ImportError: No module named MySQLdb
Failed to initialize environment. 1
Traceback (most recent call last):
File “/usr/local/lib/python2.4/site-packages/trac/scripts/admin.py”, line 617, in do_initenv
sys.exit(1)
SystemExit: 1
=================
Any idea, please help me out!
Sushmi
nick on 18 Jan 2008 at 11:30 am #
Based on the error message, it looks like you may have skipped this step:
3. Install MySQL-python so that python can interact with mysql.
Download and untar MySQL-python from http://sourceforge.net/projects/mysql-python
cd $mysqlpythonsourcedir
python setup.py build && python setup.py install
Daniel Schiavone on 21 Jan 2008 at 2:28 pm #
After installation I’m getting the following errors…
[Mon Jan 21 16:18:08 2008] [error] [client 66.93.119.89] PythonHandler trac.web.mod: Traceback (most recent call last):
[Mon Jan 21 16:18:08 2008] [error] [client 66.93.119.89] PythonHandler trac.web.mod: File “/usr/lib64/python2.4/site-packages/mod_python/apache.py”, line 287, in HandlerDispatch\n log=debug)
[Mon Jan 21 16:18:08 2008] [error] [client 66.93.119.89] PythonHandler trac.web.mod: File “/usr/lib64/python2.4/site-packages/mod_python/apache.py”, line 461, in import_module\n f, p, d = imp.find_module(parts[i], path)
[Mon Jan 21 16:18:08 2008] [error] [client 66.93.119.89] PythonHandler trac.web.mod: ImportError: No module named mod
My httpd.conf reads…
SetHandler mod_python
# added the following line
PythonInterpreter main_interpreter
PythonHandler trac.web.mod python_frontend
PythonOption TracEnv /var/www/trac/project1
PythonOption TracUriRoot /trac/
Daniel Schiavone on 21 Jan 2008 at 2:31 pm #
Looks like the space in PythonHandler trac.web.mod python_frontend was screwing it up. I removed it and now getting…
Traceback (most recent call last):
File “/usr/lib/python2.4/site-packages/trac/web/main.py”, line 406, in dispatch_request
dispatcher.dispatch(req)
File “/usr/lib/python2.4/site-packages/trac/web/main.py”, line 206, in dispatch
req.hdf = HDFWrapper(loadpaths=chrome.get_all_templates_dirs())
File “/usr/lib/python2.4/site-packages/trac/web/clearsilver.py”, line 135, in __init__
raise TracError, “ClearSilver not installed (%s)” % e
TracError: ClearSilver not installed (No module named neo_cgi)
Which someone solved above I believe.
nick on 21 Jan 2008 at 3:12 pm #
Daniel Schiavone: Based on the error message, it looks like Clearsilver is not installed. You may have skipped this step:
3. Install Clearsilver, a templating package that trac depends on.
1. Download and untar clearsilver from http://www.clearsilver.net/downloads/
2. Compile
cd $clearsilversourcedir; ./configure && make && make install
-Nick
gabe on 24 Jan 2008 at 1:26 pm #
Thanks for the guide… 2 small issues I ran into, I needed to install python-devel before installing MySQL-python, and I needed to recompile my MySQL installation with the option: –enable-thread-safe-client Below are the errors I got:
Error:
In file included from _mysql.c:29:pymemcompat.h:10:20: error: Python.h: No such file or directory
Fix: install the python-devel package before setup/install of MySQL-python
Error: /usr/bin/ld: cannot find -lmysqlclient_r
Fix: recompile mysql with –enable-thread-safe-client
Otherwise, it went smoothly. Piece of cake.
Shack Dougall on 08 Feb 2008 at 10:29 pm #
Great instructions! Thanks!
I couldn’t get mod_python to work with Trac. It never gave me an error message, but just silently failed. Possibly, it was related to the fact that I have a WordPress blog at the root of my website which does a lot of url rewriting.
Anyway, mod_wsgi is also simple to setup and worked immediately for me.
joel on 25 Feb 2008 at 8:31 pm #
This is what I used.
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /srv/trac
PythonOption TracUriRoot /trac
SetEnv PYTHON_EGG_CACHE /srv/trac/cache
PythonDebug On
The space in the PythonHandler line was causing me problems. I also needed to add the PYTHON_EGG_CACHE line.
Badoviatgat on 24 Mar 2008 at 4:11 am #
I’d prefer reading in my native language, because my knowledge of your languange is no so well.
Richard on 29 Mar 2008 at 2:27 pm #
I only got as far as “python setup.py build && python setup.py install”
and got a shed load of errors, such as:
_mysql.c:545: warning: statement with no effect
_mysql.c:546: warning: implicit declaration of function ‘mysql_init’
_mysql.c:546: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:546: warning: statement with no effect
_mysql.c:549: warning: implicit declaration of function ‘mysql_options’
_mysql.c:549: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:549: error: ‘MYSQL_OPT_CONNECT_TIMEOUT’ undeclared (first use in this function)
_mysql.c:553: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:553: error: ‘MYSQL_OPT_COMPRESS’ undeclared (first use in this function)
_mysql.c:554: error: ‘CLIENT_COMPRESS’ undeclared (first use in this function)
_mysql.c:554: error: invalid operands to binary |
_mysql.c:554: error: incompatible types in assignment
_mysql.c:554: warning: statement with no effect
_mysql.c:557: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:557: error: ‘MYSQL_OPT_NAMED_PIPE’ undeclared (first use in this function)
_mysql.c:558: warning: comparison of distinct pointer types lacks a cast
_mysql.c:559: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:559: error: ‘MYSQL_INIT_COMMAND’ undeclared (first use in this function)
_mysql.c:560: warning: comparison of distinct pointer types lacks a cast
_mysql.c:561: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:561: error: ‘MYSQL_READ_DEFAULT_FILE’ undeclared (first use in this function)
etc. etc.
any ideas or help would be much appreciated
Vu Huy Phuong on 03 Apr 2008 at 2:15 am #
to Richard:
I have had the same errors with you, I read the README file and found that I should install mysql-devel (and python-devel if neccesary) package before, then I tried and it’s solved. Try it yourself and let me know!
John on 15 Apr 2008 at 7:03 pm #
for some reason even after I installed mod_python I get
Invalid command ‘PythonHandler’, perhaps misspelled or defined by a module not included in the server configuration
I checked in my /usr/local/apache/modules and mod_python.so isn’t there… so whether I do a yum install or manually compile mod_python it never gets installed in the modules directory…
any suggestions??
John on 15 Apr 2008 at 7:25 pm #
nevermind, for some reason ./configure –with-apxs=/usr/local/apache/bin/apxs before compiling made it work…
John on 15 Apr 2008 at 7:49 pm #
well now I get another problem…
using
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv $pathtoyourtracproject
PythonOption TracUriRoot /trac/
where $pathtoyourtracproject is replaced by my path, I get an 500 internal error on my server… any clue why?
Pieter on 16 May 2008 at 6:39 am #
I’m having the same problem as John. I get a 500 internal error.
The output of /var/log/httpd/error_log
[Fri May 16 15:49:00 2008] [error] [client 10.10.3.18] PythonHandler trac.web.mod: ImportError: No module named mod
[Fri May 16 15:49:04 2008] [error] [client 10.10.3.18] PythonHandler trac.web.mod: Traceback (most recent call last):
[Fri May 16 15:49:04 2008] [error] [client 10.10.3.18] PythonHandler trac.web.mod: File “/usr/lib/python2.4/site-packages/mod_python/apache.py”, line 287, in HandlerDispatch\n log=debug)
[Fri May 16 15:49:04 2008] [error] [client 10.10.3.18] PythonHandler trac.web.mod: File “/usr/lib/python2.4/site-packages/mod_python/apache.py”, line 461, in import_module\n f, p, d = imp.find_
module(parts[i], path)
[Fri May 16 15:49:04 2008] [error] [client 10.10.3.18] PythonHandler trac.web.mod: ImportError: No module named mod
Pieter on 16 May 2008 at 7:49 am #
The problem I was having was the following:
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.
So I made a directory under /usr/lib/trac/plugins-cache with the right permissions (777) so that the Apache user can write into it.
I’ve added in my httpd.conf:
SetEnv PYTHON_EGG_CACHE /usr/lib/trac/plugin-cache
Restarted Apache and tadaaaa, it works!
More info about Trac Plugins/Problems here: http://trac.edgewall.org/wiki/TracPlugins
Installing Trac on CentOS 5 « Compulsivo, Inc. on 16 May 2008 at 4:41 pm #
[…] (because it sucks and has been slain by Git). If you need SVN support, check out the posts by Nick or Daniel […]
Wei-Yin Chen on 18 May 2008 at 3:10 pm #
If you have Dag repository set up, you may just do “yum install trac” and most of the tedious steps can be skipped.