= Installing Trac with Subversion on Ubuntu = The goal of this tutorial is to demostrate how to setup a Subversion <-> Trac enviroment on Ubuntu 11.04. A MySQL database and Subversion Python bindings are going to be used. Please note that only general instructions are provided, and it's asummed that you have basic knowledge on Linux administration. '''Note''': for a full installation tutorial on Trac, please read TracInstall [[PageOutline(2-3,Installation Steps,inline)]] == Installing the software and its dependencies == === Base packages === In order to get Trac and Subversion installed, you will need to get a few packages listed below. Also, make sure your system is updated. {{{ sudo apt-get install apache2 libapache2-mod-python python-setuptools python-genshi mysql-server python-mysqldb }}} === Subversion === Installing Subversion (SVN) is pretty straight forward. Just run: {{{ sudo apt-get install subversion }}} === Trac === There are different ways of installing Trac. But since this tutorial is focused on Ubuntu, you'll do the Ubuntu way: {{{ sudo apt-get install trac }}} == Configuring == This part is maybe the most important section on this tutorial. You'll learn how to syncronize Trac and Subversion in order to be able to see on your Trac Project website what's going on in your repository and also how to automate some tasks. === Subversion === ==== Creating the project ==== You may already know how to do this, but let's make a review just in case. Create a directory to store the SVN projects: {{{ sudo mkdir /var/lib/svn }}} Create a the project directory: {{{ sudo mkdir /var/lib/svn/YourProject }}} Use svnadmin to create a project in the previously created folder: {{{ sudo svnadmin create /var/lib/svn/YourProject }}} In order to perform some changes to the project, Trac needs write access to it: {{{ sudo chown -R www-data /var/lib/svn/YourProject }}} === Setup the MySQL database === Before installing Trac, you'll need to setup the MySQL database. Log into MySQL database, using the root credentials you've setup during the installation: {{{ mysql -u root -p }}} Once logged in, create the database for Trac: {{{ CREATE DATABASE trac DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; }}} Now create the username which Trac is going to use to connect to the database: {{{ GRANT ALL ON trac.* TO trac@localhost IDENTIFIED BY 'yourpassword'; }}} You can now exit the MySQL command line. === Trac === ==== Initiate the enviroment Let's create a directory to contain all the Trac project (just like we did for SVN projects). {{{ sudo mkdir /var/lib/trac }}} Create a directory where to store the Trac project in: {{{ sudo mkdir /var/lib/trac/YourProject }}} As you did for Subversion, change the ownership of the project files to Apache's user www-data: {{{ sudo chown -R www-data:www-data /var/lib/trac/YourProject }}} Use trac-admin to create the new project: {{{ sudo trac-admin /var/lib/trac/YourProject initenv }}} You will need to fill in some information, like the project name. Also, it will ask you for the MySQL connection string. Input the following (according to the way we did setup the MySQL database in the step 2.2). {{{ mysql://trac:yourpassword@localhost/trac }}} If the MySQL default engine wasn't InnoDB, you might need to convert the tables tha trac-admin has just created. Issue the following: {{{ ALTER TABLE `attachment` ENGINE = InnoDB; \ ALTER TABLE `auth_cookie` ENGINE = InnoDB; \ ALTER TABLE `cache` ENGINE = InnoDB; \ ALTER TABLE `component` ENGINE = InnoDB; \ ALTER TABLE `enum` ENGINE = InnoDB; \ ALTER TABLE `milestone` ENGINE = InnoDB; \ ALTER TABLE `node_change` ENGINE = InnoDB; \ ALTER TABLE `permission` ENGINE = InnoDB; \ ALTER TABLE `report` ENGINE = InnoDB; \ ALTER TABLE `repository` ENGINE = InnoDB; \ ALTER TABLE `revision` ENGINE = InnoDB; \ ALTER TABLE `session` ENGINE = InnoDB; \ ALTER TABLE `session_attribute` ENGINE = InnoDB; \ ALTER TABLE `system` ENGINE = InnoDB; \ ALTER TABLE `ticket` ENGINE = InnoDB; \ ALTER TABLE `ticket_change` ENGINE = InnoDB; \ ALTER TABLE `ticket_custom` ENGINE = InnoDB; \ ALTER TABLE `version` ENGINE = InnoDB; \ ALTER TABLE `wiki` ENGINE = InnoDB; }}} ==== Explicit syncronization ==== '''Note''': For more information about the Explicit Syncronization method, plesae read TracRepositoryAdmin#ExplicitSync First, edit the '''trac.ini''' file, located in ''/var/lib/trac/YourProject/conf/''. Modify the "repository_sync_per_request" directive and set it to an empty value. Now you need to create the Subversion hooks. First, create the post-commit hook the in ''/var/lib/svn/YourProject/hooks/'' directory, with the following content: {{{ #!/bin/sh export PYTHON_EGG_CACHE="/path/to/dir" /usr/bin/trac-admin /path/to/env changeset added "$1" "$2" }}} ===== Automatic reference to the SVN changesets in Trac tickets ===== === Apache === ==== Set up Trac handling ==== ==== Authentication ==== == Workflow examples ==