Setup Trac w/ multiple projects, mod_wsgi, LDAP & MySQL – Ubuntu 12.10

[[[TOC]]]
—–
= Installation =

{{{
sudo apt-get install -y apache2 libapache2-mod-python python-setuptools
python-genshi mysql-server python-mysqldb
easy_install a2enmod #< Base Packages sudo apt-get install -y libapache2-mod-wsgi #< WSGI support sudo apt-get install -y subversion #< Subversion (not covering the config) sudo easy_install trac #< Trac }}} ------------ = Prep MySQL = * Log in {{{ mysql -u root -p$PASSWORD }}} * Create the database. If setting up multiple instances, you will want to replace trac with a unique project name. {{{ CREATE DATABASE trac DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; }}} * Setup MySQL Permissions {{{ GRANT ALL ON trac.* TO trac@localhost IDENTIFIED BY '$NOT_THE_ROOT_PASSWORD'; }}} * Exit {{{ exit }}} ---------- = Configure Trac = * Create Trac User {{{ sudo useradd trac_project }}} * Create Trac projects directory {{{ sudo mkdir -p /var/lib/trac/sites }}} * Create a directory for each of the Trac projects {{{ sudo mkdir /var/lib/trac/sites/trac_project }}} * Create the shared egg_cache directory {{{ sudo mkdir /var/lib/trac/eggs }}} * Initialize the project with trac-admin. {{{ sudo trac-admin /var/lib/trac/trac_project initenv }}} * Fill in the prompts, when asked for the `Database connection string`, input the MySQL information from above {{{ mysql://trac:mysqluserpassword@localhost/trac }}} ------- = Apache Config (WSGI - mod_fcgid) = * Enable mod_rewrite {{{ sudo a2enmod rewrite }}} * Create the www directory {{{ mkdir /var/www/trac }}} * Generate the cgi scripts for each project {{{ trac-admin /var/lib/trac/trac_project deploy /var/www/trac/trac_project }}} * Create the parent env wsgi file {{{ sudo nano /var/www/trac/trac.wsgi }}} {{{ import sys sys.stdout = sys.stderr import os os.environ['TRAC_ENV_PARENT_DIR'] = '/var/lib/trac/sites' os.environ['PYTHON_EGG_CACHE'] = '/var/lib/trac/eggs' import trac.web.main application = trac.web.main.dispatch_request }}} * Create the script alias in Apache configuration {{{ # Trac WSGI WSGIDaemonProcess trac_project user=trac_project group=trac_project threads=25 WSGIDaemonProcess poroject_2 user=poroject_2 group=poroject_2 threads=25 #< Sample of how to add another Trac instance RewriteEngine On RewriteCond %{REQUEST_URI} ^/trac/([^/]+) RewriteRule . - [E=trac.process_group:%1,\ E=trac.env_path:/var/lib/trac/sites/%1] WSGIScriptAliasMatch ^/trac/([^/]+) /var/www/trac/trac.wsgi
WSGIProcessGroup %{ENV:trac.process_group}
WSGIApplicationGroup %{GLOBAL}
Order allow,deny

# For LDAP Auth through Apache

AuthType Basic
AuthName “Trac Authentication”
AuthBasicProvider ldap
AuthzLDAPAuthoritative off
AuthLDAPBindDN “binduser@domain.com”
AuthLDAPBindPassword “$BIND_USER_PASSWD”
AuthLDAPURL “ldap://$LDAP_SERVER:389/DC=domain,DC=com?sAMAccountName?sub?(&(objectClass=organizationalPerson))”
Require valid-user

}}}
* Modify the permissions so that the specified user can work with the directory
{{{
sudo chown -R trac_project:trac_project /var/lib/trac
}}}
* Edit the trac configuration to enable the login form
{{{
sudo nano /var/lib/trac/trac_project/conf/trac.ini
}}}
{{{
[account-manager]
authentication_url = /trac/login
password_store = HttpAuthStore

[components]
acct_mgr.http.HttpAuthStore = enabled
}}}
* Make sure the cgi paths are executable by the web server
{{{
chmod -R +x /var/www/trac
}}}
* Restart web server
{{{
sudo service apache2 restart
}}}
* Now going to $URL/trac/$PROJECT will take you to your newly created project.
* You will need to add your LDAP user to the admin group of all the projects
{{{
sudo trac-admin /var/lib/trac/trac_project permission add $LDAP_USER TRAC_ADMIN
}}}
——
= Credits =
[[http://trac.edgewall.org/wiki/Ubuntu-11.04-Subversion]]
[[http://trac.edgewall.org/wiki/TracFastCgi]]
[[http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac]]


Posted

in

, ,

by

Comments

2 responses to “Setup Trac w/ multiple projects, mod_wsgi, LDAP & MySQL – Ubuntu 12.10”

  1. Ivan Monroy Avatar
    Ivan Monroy

    Gracias.

    1. dlasley Avatar

      De Nada – Thanks for reading my blog!

Leave a Reply to Ivan Monroy Cancel reply

Your email address will not be published. Required fields are marked *