July 2014
M T W T F S S
« Mar    
 123456
78910111213
14151617181920
21222324252627
28293031  
151

Refs

Categories

Archives

profile for slm on Stack Exchange, a network of free, community-driven Q&A sites

Installing Trac on CentOS 5

I started installing trac a few days ago on one of my OpenVZ VE instances running CentOS 5. I got to the point where I needed to install the gitPlugin when I realized, oh crap, I need Python 2.5. Installing major upgrades to python can be a bit of a pain. Especially on RedHat flavored distros. So I setup a separate OpenVZ VE instance just to try out doing an install of Python 2.5 along side my existing Python 2.4 install. Refer to my previous post about installing Python 2.5 on CentOS 5.

So this is the moment of truth. Installing Trac and all it’s plugins so that they are using the 2.5 install.

Point python to python25
1
% alias python=/usr/bin/python25

That was easy enough.

Trac

So now lets install Trac. I’m going to use easy_install to do this. This gives me the latest version that’s available, 0.11.3. Doing it this way will automatically install Genshi for me as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
% easy_install trac
Searching for trac
Reading http://pypi.python.org/simple/trac/
Reading http://projects.edgewall.com/trac
Reading http://projects.edgewall.com/trac/wiki/TracDownload
Reading http://trac.edgewall.com/
Best match: Trac 0.11.3
Downloading ftp://ftp.edgewall.com/pub/trac/Trac-0.11.3.zip
Processing Trac-0.11.3.zip
Running Trac-0.11.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_WZSG4/Trac-0.11.3/egg-dist-tmp-TCkvCy
Adding Trac 0.11.3 to easy-install.pth file
Installing trac-admin script to /usr/bin
Installing tracd script to /usr/bin
 
Installed /usr/lib/python2.5/site-packages/Trac-0.11.3-py2.5.egg
Processing dependencies for trac
Searching for Genshi>=0.5
Reading http://pypi.python.org/simple/Genshi/
Reading http://genshi.edgewall.org/
Reading http://genshi.edgewall.org/wiki/Download
Best match: Genshi 0.5.1
Downloading http://ftp.edgewall.com/pub/genshi/Genshi-0.5.1-py2.5-linux-i686.egg
Processing Genshi-0.5.1-py2.5-linux-i686.egg
Moving Genshi-0.5.1-py2.5-linux-i686.egg to /usr/lib/python2.5/site-packages
Adding Genshi 0.5.1 to easy-install.pth file
 
Installed /usr/lib/python2.5/site-packages/Genshi-0.5.1-py2.5-linux-i686.egg
Finished processing dependencies for trac

Install subversion

To go any further with installation of plugins for trac we need to install subversion. This is required because we’re going to be using easy_install to install directly form subversion repos.

1
yum -y install subversion
Installing GitPlugin
1
2
3
4
5
6
7
8
9
10
11
12
13
% easy_install http://trac-hacks.org/svn/gitplugin/0.11/
Downloading http://trac-hacks.org/svn/gitplugin/0.11/
Doing subversion checkout from http://trac-hacks.org/svn/gitplugin/0.11/ to /tmp/easy_install-t8DYh8/0.11
Processing 0.11
Running setup.py -q bdist_egg --dist-dir /tmp/easy_install-t8DYh8/0.11/egg-dist-tmp-5Iug4o
warning: install_data: setup script did not provide a directory for 'COPYING' -- installing right in 'build/bdist.linux-i686/egg'
warning: install_data: setup script did not provide a directory for 'README' -- installing right in 'build/bdist.linux-i686/egg'
zip_safe flag not set; analyzing archive contents...
TracGit 0.11.0.1 is already the active version in easy-install.pth
 
Installed /usr/lib/python2.5/site-packages/TracGit-0.11.0.1-py2.5.egg
Processing dependencies for TracGit==0.11.0.1
Finished processing dependencies for TracGit==0.11.0.1

You can ignore the warnings about the 2 files. These aren’t critical.

Building the mod_python RPM for Python 2.5
1
2
3
4
5
6
# get the srpm for mod_python
wget http://mirror.centos.org/centos/5/os/SRPMS/mod_python-3.2.8-3.1.src.rpm
# install the srpm
rpm -ivh mod_python-3.2.8-3.1.src.rpm
# modify .spec file
vim /usr/src/redhat/SPEC/mod_python.spec

NOTE: changes to .spec file

# change this line
BuildPrereq: httpd-devel >= 2.0.40-6, python, python-devel, autoconf
# to this line
BuildPrereq: httpd-devel >= 2.0.40-6, python, python25-devel, autoconf

# change this line
%configure --with-apxs=%{_sbindir}/apxs --with-max-locks=4
# to this line
%configure --with-apxs=%{_sbindir}/apxs --with-max-locks=4 --with-python=/usr/bin/python25

# add this line to the end of the %files section
%{_libdir}/python*/site-packages/mod_python*.egg-info

NOTE: this site was a bit useful in figuring out what I needed to change to compile mod_python with python 2.5.

Now rebuild & install the rpm using the new spec file.

1
2
rpmbuild -ba /usr/src/redhat/SPEC/mod_python.spec
rpm -ivh /usr/src/redhat/RPMS/i386/mod_python-3.2.8-3.1.i386.rpm
Creating a trac.conf file for apache
1
2
3
4
5
6
7
8
9
# /etc/httpd/conf.d/trac.conf
#
# trac
<Location /projects>
  SetHandler mod_python
  PythonHandler trac.web.modpython_frontend 
  PythonOption TracEnvParentDir /projects/trac/projects
  PythonOption TracUriRoot /projects
</Location>

Customize this file to where you’re planning on keeping your trac project directories. I keep mine all in the same area, i.e. /projects/trac/projects.

NOTE: There are further details about getting apache + mod_python working through the trac.conf & python.conf files under the directory /etc/httpd/conf.d. You can read about it on this trac mod_python page. Also there is information about how to go about securing apache + trac there as well.

Create a git repo
1
2
3
4
mkdir /projects/code_repos/git/scripts
cd /projects/code_repos/git/scripts
git --bare init
Initialized empty Git repository in /projects/code_repos/git/scripts
Start up apache
1
2
3
4
% /etc/init.d/httpd configtest
Syntax OK
% /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
Create a trac project
1
2
3
cd /projects/trac/projects/
trac-admin ./apache_matrix initenv
trac-admin ./scripts initenv
Modify project scripts’ trac.ini file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# modify the repo location and repo type
[trac]
...
repository_dir = /projects/code_repos/git/scripts/.git
repository_type = git
...
 
# enable the GitPlugin for this project
[components]
tracext.git.* = enabled
 
# add a git section with this content
[git]
## let Trac cache meta-data via CachedRepository wrapper; default: false
cached_repository = true
## disable automatic garbage collection for in-memory commit-tree cache; default: false
persistent_cache = true
## length revision sha-sums should be tried to be abbreviated to (must be >= 4 and <= 40); default: 7
shortrev_len = 6
## executable file name (optionally with path) of git binary; default: 'git'
git_bin = /usr/bin/git

Now try accessing the server at http://Site URL/projects/scripts. You should see a Browse Source button. Through this you should now see your git repo!

Browsing with the GitPlugin

Browsing with the GitPlugin

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>