Installing Trac and Subversion
From InstallationWiki
| Official Page |
| Project Documentation |
| Download |
|
Contents |
[edit] Installing the Components
If you are using Microsoft Windows, you will have to install Apache first, then Subversion, and finally Trac. If Debian or Ubuntu is your preference, then we need to follow the instructions for Subversion and Trac, as the way in which the software is packaged on those platforms makes our life easier for us.
[edit] Installing Apache
[edit] Windows
1. Download and run apache_2.0.61-win32-x86-no_ssl.msi from http://www.mirrorservice.org/sites/ftp.apache.org/httpd/binaries/win32/apache_2.0.61-win32-x86-no_ssl.msi. The following window will be observed:
2. Click Next.
3. Select I accept the terms in the license agreement and click Next.
4. Click Next.
4. Change the Network Domain, Server Name, and Administrator's Email Address as required and click Next.
5. Click Next to accept the Typical installation.
7. Change the installation folder if required (not recommended) and click Next.
8. Click Install to start the installation.
9. Wait while the installation takes place.
10. Click Finish to complete the installation.
[edit] Linux
We will discuss Ubuntu and Debian in the following section.
Installation of Apache is far easier under Ubuntu and Debian as the package management software used will handle the dependencies for us.
To install Apache, simply run the following command from a console:
$ sudo apt-get install apache2
Answer yes when prompted.
[edit] Installing Subversion
[edit] Windows
1. Download and run svn-1.4.5-setup.exe from http://subversion.tigris.org/files/documents/15/39559/svn-1.4.5-setup.exe. You should observe the following screenshot:
2. Click Yes and then Next to progress and pass the welcome screen.
3. Select I accept the agreement and click Next.
4. Click Next.
5. Change the installation path if required (not recommended) and click Next.
6. Change the folder name if required (not recommended) and click Next.
7. Deselect the Desktop icons and Quick Launch icons options, but leave the Apache modules option selected and click Next.
8. Confirm the details and click Install.
9. Wait while the installation takes place.
10. Click Next.
11. Click Finish.
You can test the installation by opening a command prompt and typing svn --version then pressing Enter. If everything is working OK we should see a result similar to the following (most of the output will have flowed off the screen):
[edit] Linux
We will discuss Ubuntu and Debian in the following section.
Things are much easier under Ubuntu and Debian. To install Subversion simply use the following instructions.
[edit] Client
To install Subversion on your client, use the following command from the console:
$ sudo apt-get install subversion
Answer yes when are asked to confirm the action, and that is it!
[edit] Server
Installing the server components under Linux is significantly easier than on Microsoft Windows. Use the following command from the console:
$ sudo apt-get install subversion libapache2-svn
Again answer yes when prompted. This will automatically install Subversion, Apache, and the Apache Subversion module for us all in one go.
[edit] Installing Trac
This section covers detailed, step-by-step instructions for installing Trac and its dependencies, and covers Microsoft Windows and Linux.
Trac is very easy to install, but has a number of dependencies that must be satisfied first. As Trac is written in Python, our first requirement is obvious. There are several versions of Python available, but the recommended version is 2.4. For data storage Trac can use a variety of databases. SQLite was the only original option, and remains the most popular, primarily because it is the easiest to configure. For these reasons the instructions that follow assume you will also use SQLite.
SQLite is unusual in that there is no server software to install. Instead databases are single files, which can be used by any application that uses the SQLite library. This means that for Trac, we need to have the Python SQLite library installed. In order to communicate with Subversion, Trac requires the Python Subversion library. Finally it uses ClearSilver for its template system.
[edit] Microsoft Windows
The following section describes the required installations.
[edit] Python
1. Download and run python-2.4.4.msi from http://www.python.org/ftp/python/2.4.4/python-2.4.4.msi. The following window will be observed.
2. Leave Install for all users selected and click Next.
3. Click Next to accept the default destination directory.
4. Leave all features selected and click Next'.'
5. Wait while the installation takes place.
6. Click Finish to complete the installation.
[edit] Python Subversion Bindings
1. Download and run svn-python-1.4.4.win32-py2.4.exe from http://subversion.tigris.org/files/documents/15/38214/svn-python-1.4.4.win32-py2.4.exe.
2. Click Next to skip the welcome screen.
3. Ensure that Python 2.4 is selected and click Next.
4. Click Next to start the installation.
5. Click Finish to complete the installation.
[edit] Python SQLite Bindings
1. Download and run pysqlite-2.3.5.win32-py2.4.exe from http://initd.org/pub/software/pysqlite/releases/2.3/2.3.5/pysqlite-2.3.5.win32-py2.4.exe.
2. Click Next to skip past the welcome screen.
3. Ensure Python 2.4 is selected and click Next.
4. Click Next to start the installation.
5. Click Finish to complete the installation.
[edit] ClearSilver
1. Download and run clearsilver-0.9.14.win32-py2.4.exe from http://www.clearsilver.net/downloads/win32/clearsilver-0.9.14.win32-py2.4.exe.
2. Click Next on the welcome screen.
3. Ensure Python 2.4 is selected and click Next.
4. Click Next to start the installation.
5. Click Finish to complete the installation.
[edit] Trac
1. Download and run trac-0.10.4.win32.exe from http://ftp.edgewall.com/pub/trac/trac-0.10.4.win32.exe.
2. Click Next at the welcome screen.
3. Ensure Python 2.4 is selected and click Next.
4. Click Next to start the installation.
5. Click Finish to complete the installation. Linux
Installing Trac under Linux requires us to carry out the same two steps as for Microsoft Windows installing the dependencies, and installing Trac itself.
[edit] Ubuntu and Debian
[edit] Installing the Dependencies
These can be installed with the following command:
$ sudo apt-get install python2.4-pysqlite2 python2.4-subversion python-clearsilver
[edit] Installing Trac
1. Download Trac with:
wget http://ftp.edgewall.com/pub/trac/trac-0.10.4.tar.gz
2. Extract the files with:
tar -xzf trac-0.10.4.tar.gz
3. Change into the extracted folder with:
cd trac-0.10.4
4. Run the installation with:
sudo python setup.py install
[edit] Configuration
Keeping It Organized
To make our lives easier, or for our system administrators, we need to keep the files for our projects together in a sensible fashion. To do this, we will first create a single folder projects and then create sub-folders for each component svn, and trac for subversion, and Trac, respectively which will in turn hold the folders for our individual projects.
We will be setting up our directory structure based around our tools each project will have a subdirectory under a folder for each component. We could approach it from the opposite direction and have a single directory per project with a folder for each component underneath, but this would create more administrative work as both Subversion and Trac can handle multiple projects nested in a single folder, but require manual configuration for multiple projects in multiple folders.
Before we go any further it is time to create some folders to store our Subversion and Trac repositories, and check that everything is working as expected. We're going to keep everything in the projects folder, which we will place in the root of the C: drive (Microsoft Windows) or the root partition (Linux).
The followings steps should be performed as a user with administrative rights from a command prompt (Start menu, Run, type cmd and click OK) for Microsoft Windows, or in a terminal as root, either directly (Debian) or via sudo (Ubuntu) for Linux.
1. For Microsoft Windows only, Type c: and press Enter.
2. Type cd \ (Microsoft Windows) or cd / (Linux) and press Enter.
3. Type mkdir projects and press Enter.
4. Type cd projects and press Enter.
5. Type mkdir svn trac files and press Enter.
[edit] Customizing trac.cgi
For Microsoft Windows we need to create a copy of the main Trac script and tweak it to use the version of Python we have installed.
1. Open a command prompt (Start menu, Run, type cmd, and click OK).
2. Type copy "C:\Python24\share\trac\cgi-bin" "C:\Projects\" and press Enter.
3. Type exit and press Enter to close your command prompt.
4. Open C:\Projects\trac.cgi in a text editor.
5. Change the first line to:
#!C:/Python24/python.exe
6. Save and close the file.
We can safely ignore it if we are using Linux.
[edit] Configuring Apache
Installation of our components is only part of the story, because we need to configure them to work together. We are using our web server Apache to provide and control, as we will discover later access to our components. At the moment it is only configured for typical web server activities, so we need to expand on that.
Before we delve into configuration details, we need to know where to make our changes. Apache is controlled through a collection of configuration files that differ depending on the platform we are using. On Microsoft Windows the only file we really need to be concerned with is httpd.conf, which can be found in C:\Program Files\Apache Group\Apache2\conf\. Things are slightly more complicated under Linux as Debian and Ubuntu are configured to support virtual hosts out of the box, and configuration for individual hosts and modules is abstracted into individual files stored in /etc/apache2/sites-available and /etc/apache2/mods-available respectively. However, the simple presence of a file does not mean that it is recognized by Apache they first have to be enabled. Fortunately unless we chose to use virtual hosts we need to enable only a couple of modules, and we can keep all our configuration in the file for the default host, which is unsurprisingly called default.
As already hinted, we need to make a few changes to the default Apache configuration. First of all we need to enable the dav_fs module, and then we need to append our configuration for dealing with serving multiple Trac projects and Subversion repositories. Finally we will implement authentication mechanisms.
Now we can tackle the much bigger task of configuring Apache to our requirements. Although this could be tackled as a whole, we are going to break it down into pieces so that we understand what each part does.
First we need to open the configuration file in a text editor ready to configure it. For Microsoft Windows this file is C:\Program Files\Apache Group\Apache2\conf\httpd.conf while for Ubuntu and Debian we will be using /etc/apache2/sites-available/default.
[edit] Enabling dav_fs
The instructions will diverge depending on the platform chosen.
For Microsoft Windows we need to edit our configuration file as follows:
1. Remove the leading comment marker (# ) from line 164.
2. Save the file.
For Ubuntu and Debian we need to execute the follow command as root:
1. a2enmod dav_fs
Both have the same result of enabling the dav_fs module.
Now we will append a series of sections to our configuration file. We can safely make all the changes in one go, but we will look at each set of changes individually so we can understand what they do.
First we will tell Apache that any and all requests for the (virtual) folder projects should be handled by Trac.
For Microsoft Windows:
ScriptAlias /projects C:/Projects/trac.cgi
For Linux:
ScriptAlias /projects /usr/share/trac/cgi-bin/trac.cgi
Next we will specify an environment variable that tells Trac that it is serving multiple projects and where to find those projects on the filesystem.
<Location "/projects"> SetEnv TRAC_ENV_PARENT_DIR "/projects/trac" </Location>
Trac supports two methods of authentication HTTP and sessions.For now we need to know that we will be using HTTP authentication so that Apache can handle authentication to Trac, and Subversion for us.
First we will make sure that anyone accessing the login link within any project hosted on our server is required to be authenticated by Apache.
<LocationMatch "/projects/[^/]+/login"> AuthType Basic AuthName "Trac Environment" AuthUserFile /projects/projects.passwd Require valid-user </LocationMatch>
For Microsoft Windows the line AuthUserFile should be changed to: C:/Projects/projects.passwd.
Now we will ensure that all access to Subversion via Apache is authenticated.
<Location /svn> DAV svn SVNParentPath /projects/svn AuthType Basic AuthName "Subversion Repositories" AuthUserFile /projects/projects.passwd Require valid-user </Location>
As before AuthUserFile should be changed for Microsoft Windows. Additionally SVNParentPath should be changed to C:/Projects/svn.
Now we can save our configuration file and restart Apache so that our changes will be recognized.
[edit] Source
The source of this content is Appendix Section of [1] by David J Murphy (Packt Publishing , 2007).
[edit] Alternate Installation
The BitNami project provides a free, open source installer for Trac and Subversion
