My Life Stream
the last.fm app for the iPhone is awesome, much better than the Pandora app with it's really low quality stream 1 day ago

Installing SVN and Trac on Fedora Core 6 for Apache

For some reason or another I could not find good documentation on installing Subversion and Trac on fc6 while also using Apache so I’ve simply just documented what I’ve learned and just implemented on my own system.

This tutorial is about the installation of a development enviroment on FC6 it’s not a how-to for using it. If you need to know more I recommend reading Version Control with Subversion (I just ordered it).

Requirements

You need to install these packages before we start (use yum install package-name).

  • Trac - documentation wiki and bug-tracking software.
  • Subversion - source code control system.
  • Apache - duh.

/home/svn

I’ve gone ahead and installed this development environment in /home/svn not /srv/ or var/www like other resources prefer. If you want to install svn in a different directory please change the below instruction appropriately.

Subversion

Within you’ll need to create a new, empty subversion repository. Do this by running this command

$ svnadmin create /home/svn

You’ll need to establish the trunk/tags/branches directory structure. Create a temporary directory somewhere, i.e. /tmp/newsvn. Go there and create three subdirectories called, “branches” “tags” and “trunk”. Then import those directories into svn

$ svn import /tmp/newsvn file:///home/svn -m “initial import”

The terminal should print

Adding /tmp/newsvn/trunk
Adding /tmp/newsvn/branches
Adding /tmp/newsvn/tags
Committed revision 1.

Subversion now works and can be accessed by going to http://localhost/svn. If you’re receiving an error 13 it’s caused by permissions problems and running the below command will clear it up,

$ chcon -R -h -u system_u -t httpd_sys_content_t /home/svn

Trac environment

Before you start you’ll want to create a directory for trac. I prefer to have it within my SVN directory,

$ mkdir -p /home/svn/trac

To initiate trac you will need to run,

$ trac-admin /home/svn/trac initenv

To create the new enviroment you will be ask a few questions. The only two that you should be concerned with are

Project Name [My Project]> Trac

This is exactly what it says, just name it anything you want.

Path to repository [/path/to/repos]> /home/svn

This is important. Make sure to enter the full path to svn, if you’re using my settings enter /home/svn.

All of the other questions just press enter as the default settings work fine in our setup.

Authentication

I password protect both Trac and Subversion through basic authorization and store the passwords in an htpasswd file in within SVN. I wont go to deep into this how you can create more users and groups, that’s what Google is for,

$ htpasswd -cb /home/svn/htpasswd username password

Trac and Apache Setup

I recommend an entire virtual host for trac, with a name of trac.domain.com

<VirtualHost IPAddress:*>
ServerName trac.domain.com
DocumentRoot /home/svn/trac
SetEnv TRAC_ENV “/home/svn/trac”
Alias /trac/ /usr/share/trac/htdocs/
<Directory /usr/share/trac/htdocs>
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAliasMatch ^/(.*) /usr/share/trac/cgi-bin/trac.cgi/$1
<Location “/”>
AuthType Basic
AuthName “Trac”
AuthUserFile /home/svn/htpasswd
Require valid-user
</Location>
</VirtualHost>

The trac_env declaration is necessary for Trac to know where it lives, and the ScriptAliasMatch maps all access into the domain.

In order for Trac to make changes, which is pretty much the whole point, you have to grant write access for the apache user to the trac/db
subdirectory. Run,

$ chmod -R g+w /home/svn/trac/db

Then chown it to be owned by the apache user.

$ chown -R apache /home/svn/trac/db

Now you add a trac admin. Use trac-admin to add overall administration rights.

trac-admin trac
permission add username TRAC_ADMIN

Subversion and Apache setup

Although you you’re already accessed Subversion from the local filesystem, it’s time to setup Apache2 to give it a domain. Here is my Virtual Host setup,

<VirtualHost IPaddress:*>
ServerName svn.domain.com
DocumentRoot /home/svn
<Directory /home/svn>
AllowOverride All
Options MultiViews -Indexes Includes FollowSymlinks
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
# WebDAV access
<Location />
DAV svn
SVNPath /home/svn
AuthType Basic
AuthName “SVN”
AuthUserFile /home/svn/htpasswd
Require valid-user
# Allow read-only access to anyone, otherwise require
# authentication
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
</VirtualHost>

The LimitExcept will grant read-only access to any anonymous user; any other command the user will need to provide authentication.

Now you just need to make the whole Subversion repository writable, if you intend to accept checkins from others. So again run,

$ chmod -R g+w /home/svn/trac/db

$ chown -R apache /home/svn/trac/db

That’s It!

Here are some great resources for SVN and Trac:

Viewing 15 Comments

    • ^
    • v
    Cool; glad you got it working.

    There is just one typo above that you might want to change for people who are copying / pasting:

    I think
    mkdir -p /srv/trac

    should be mkdir -p /home/svn/trac to go along with the other stuff you listed, right?
    • ^
    • v
    Thanks I got it fixed.
    • ^
    • v
    Thanks, this seems quite helpful.

    With two small exceptions.

    Which config files get the <VirtualHosts etc.?

    In FC4, I yum installed mod_dav_svn and got a subversion.conf in httpd/conf.d folder.

    In FC6, svn seems to come with and I only see a trac.conf (which is where I assume we add all of the virtualhosts that you mention) but where is subversion.conf? or do we need to add it?

    bit more clarity, otherwise quite clear instructions and we'll see when i go to launch it.

    regards,
    oh4real
    • ^
    • v
    Hi

    I need help how to install svn in windows and how to protect the project by using this and how to set the username and password
    • ^
    • v
    Nice tutorial
    That really is useful.

    Thanks so much, Dan !

    /Phuongtg
    • ^
    • v
    Hi,
    When i am trying to integrate trac with apache i m getting the following error, please can any one help me i m very thaqfull.

    MOD_PYTHON ERROR

    ProcessId: 21661
    Interpreter: 'main_interpreter'

    ServerName: 'localhost.localdomain'
    DocumentRoot: '/var/www/html'

    URI: '/raj'
    Location: '/raj'
    Directory: None
    Filename: '/var/www/html/raj'
    PathInfo: ''

    Phase: 'PythonHandler'
    Handler: 'trac.web.modpython_frontend'

    Traceback (most recent call last):

    File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

    File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

    File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

    File "/usr/lib/python2.5/site-packages/trac/web/modpython_frontend.py", line 87, in handler
    gateway.run(dispatch_request)

    File "/usr/lib/python2.5/site-packages/trac/web/wsgi.py", line 87, in run
    response = application(self.environ, self._start_response)

    File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 391, in dispatch_request
    env = _open_environment(env_path, run_once=run_once)

    File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 58, in _open_environment
    env_cache[env_path] = open_environment(env_path)

    File "/usr/lib/python2.5/site-packages/trac/env.py", line 462, in open_environment
    env = Environment(env_path)

    File "/usr/lib/python2.5/site-packages/trac/env.py", line 147, in __init__
    self.verify()

    File "/usr/lib/python2.5/site-packages/trac/env.py", line 195, in verify
    fd = open(os.path.join(self.path, 'VERSION'), 'r')

    IOError: [Errno 13] Permission denied: '/home/svn/trac/venturia/VERSION'
    • ^
    • v
    Nagaraju, make sure you set something like:

    PythonOption TracEnv /home/svn/trac/venturia

    instead of

    PythonOption TracEnvParentDir ...

    Also make sure you have run trac-admin initenv
    • ^
    • v
    Hi,

    I am trying to install trac on my system iam getting the following error when i try to run my trac in a web browser

    Please help !


    MOD_PYTHON ERROR

    ProcessId: 10891
    Interpreter: 'main_interpreter'

    ServerName: 'localhost.localdomain'
    DocumentRoot: '/var/www/html'

    URI: '/venturia'
    Location: '/venturia'
    Directory: None
    Filename: '/var/www/html/venturia'
    PathInfo: ''

    Phase: 'PythonHandler'
    Handler: 'trac.web.modpython_frontend'

    Traceback (most recent call last):

    File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

    File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

    File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

    File "/usr/lib/python2.5/site-packages/trac/web/modpython_frontend.py", line 87, in handler
    gateway.run(dispatch_request)

    File "/usr/lib/python2.5/site-packages/trac/web/wsgi.py", line 87, in run
    response = application(self.environ, self._start_response)

    File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 391, in dispatch_request
    env = _open_environment(env_path, run_once=run_once)

    File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 58, in _open_environment
    env_cache[env_path] = open_environment(env_path)

    File "/usr/lib/python2.5/site-packages/trac/env.py", line 463, in open_environment
    if env.needs_upgrade():

    File "/usr/lib/python2.5/site-packages/trac/env.py", line 341, in needs_upgrade
    db = self.get_db_cnx()

    File "/usr/lib/python2.5/site-packages/trac/env.py", line 203, in get_db_cnx
    return DatabaseManager(self).get_connection()

    File "/usr/lib/python2.5/site-packages/trac/db/api.py", line 76, in get_connection
    return self._cnx_pool.get_cnx(self.timeout or None)

    File "/usr/lib/python2.5/site-packages/trac/db/pool.py", line 101, in get_cnx
    cnx = self._connector.get_connection(**self._kwargs)

    File "/usr/lib/python2.5/site-packages/trac/db/sqlite_backend.py", line 113, in get_connection
    return SQLiteConnection(path, params)

    File "/usr/lib/python2.5/site-packages/trac/db/sqlite_backend.py", line 160, in __init__
    timeout=timeout)

    SystemError: NULL result without error in PyObject_Call
    • ^
    • v
    Hi,
    I faced the SAME prob until I avoided using the python-web frontend.
    My TRAC config is attached below. Should work out-of-the-box for you.

    Regards,
    Orson
    # Replace all occurrences of /srv/trac with your trac root below
    # and uncomment the respective SetEnv and PythonOption directives.
    #
    # #SetEnv TRAC_ENV /srv/trac
    # SetEnv TRAC_ENV /var/local/trac
    #
    #
    #
    # SetHandler mod_python
    # PythonHandler trac.web.modpython_frontend
    # #PythonOption TracEnv /srv/trac
    # PythonOption /var/local/trac
    #
    #

    #Line below moved to https.conf
    ScriptAlias /trac /var/www/cgi-bin/trac.fcgi


    SetEnv TRAC_ENV "/var/local/trac"
    AuthType Basic
    AuthName "SVN Repository"
    AuthUserFile /etc/httpd/dav_svn.passwd
    # #AuthBasicAuthoritative Off
    Require valid-user

    SSLRequireSSL


    #Alias /trac/css "/usr/share/trac/htdocs/css"
    #
    # SetHandler None
    #



    SetEnv TRAC_ENV /var/local/trac"
    AuthType Basic
    AuthName "SVN Repository"
    AuthUserFile /etc/httpd/dav_svn.passwd

    Require valid-user

    SSLRequireSSL
    • ^
    • v
    Hi,
    one more thing - DISABLE Selinux by one of the following ways from the command prompt:

    1) SETENFORCE 0


    2) echo 0 > /selinux/enforce

    in case you have trouble still as SELINUX is notorious for breaking TRAC/ SVN

    Regards,

    Orson
    • ^
    • v
    Hi Orson,

    It worked thanks a lot i think its the problem with SELINUX.

    Now my trac is up and running

    Regards,
    Sandeep
    • ^
    • v
    Good to hear that. Congrats!
    • ^
    • v
    It worked. thanx alot. though it very frustrating at first since my box's servers are built from source so i have to get apr, apr-util, berkeley, swig etc and build them together with trac and subversion but it finally worked after three days on it. its so satisfying. i would finally get the trio working without this tutorial thanx again. Peace
    • ^
    • v
    *i wouldn't finally get the trio working without this tutorial thanx again. Peace

    twas a typo.
    • ^
    • v
    thank you

Trackbacks

blog comments powered by Disqus