Setting up a Subversion repository and corresponding Trac app on a (Debian/Apache) server

So the basic problem here is how to best work together productively in a programming/development project and the question which are good tools providing capabilities to potentially support and improve this. One such tool is a version control systems (VCS) which basically helps to keep the code and especially its progress under (version) control in a code repository (transparently). A specific such VCS is Subversion (a.k.a. SVN). This is at the time one of the most popular and up-to-date systems of its kind (i.e., centralized VCS). Its basic slogan is "CVS done right" (which consequently can be seen as Subversion's indirect predecessor system). There are many tools available to work with Subversion from a client/user perspective like stand-alone client apps, integration in editors, e.g., via special plugins or also complete integration in a full-blown IDE (integrated development environment). Now, what's up to do is to actually setup a Subversion system on a server and to create a code repository for a programming/development project. In this case a Debian-based OS with an Apache Web server is chosen as infrastructure. Additionally a Trac app should be installed which among other things offers nice and convenient Web visualization of the code repository (and its progress) to users. When all this is in place users can take the benefits of using Subversion for version control of the code of the project.
1 answer

How to setup Subversion and Trac app on a Debian/Apache server

As of (almost) anything there's also a good howto on the Web for that.
Here are the basic/central steps to take.

Subversion

  1. Install the required packages.
    sudo aptitude install enscript libapache2-mod-python python-docutils trac db4.3-util libapache2-svn subversion-tools
  2. Create a virtual host dir for SVN.
    sudo mkdir -p /var/local/www/svn/svn.example.com
  3. Create a development group, and add the web user to it.
    sudo addgroup example; sudo adduser www-data example
  4. Add users to the development group. These are persons that need access to the repository.
    sudo adduser username1 example
    sudo adduser username2 example
    sudo adduser username3 example
    ...
  5. Set proper permissions.
    sudo chmod 2770 /var/local/www/svn/svn.example.com
  6. Set up the repository.
    sudo svnadmin create /var/local/www/svn/svn.example.com
  7. Clear the current password file (we'll be using HTTPS).
    sudo rm /var/local/www/svn/svn.example.com/conf/passwd
    sudo touch /var/local/www/svn/svn.example.com/conf/passwd
  8. Allow the group to write to the repository.
    sudo chmod -R g+w /var/local/www/svn/svn.example.com
  9. Set proper file ownership.
    sudo chown -R www-data:example /var/local/www/svn/svn.example.com
  10. Set the repository access permissions. (see)
    sudo vi /var/local/www/svn/svn.example.com/conf/authz
  11. Create a dir for the log files.
    sudo mkdir /var/log/apache2/svn.example.com
  12. Add the site to the log rotation list.
    sudo vi /etc/logrotate.d/apache2
  13. Configure the virtual host.
    sudo vi /etc/apache2/sites-available/svn.example.com

    # Subversion Configuration
    <VirtualHost [server's IP address]:80>
    ServerName svn.example.com
    Redirect / https://svn.example.com/
    </VirtualHost>
    <VirtualHost [server's IP address]:443>
    ServerName svn.example.com
    <Location />
    DAV svn
    AuthType Basic
    AuthName "svn.example.com"
    AuthUserFile /var/local/www/svn/svn.example.com/conf/passwd
    AuthzSVNAccessFile /var/local/www/svn/svn.example.com/conf/authz
    SVNPath /var/local/www/svn/svn.example.com
    Require valid-user
    </Location>
    CustomLog /var/log/apache2/svn.example.com/access.log combined
    ErrorLog /var/log/apache2/svn.example.com/error.log
    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/apache.pem
    # Add this once there is a real (non self-signed) certificate.
    # SSLCertificateKeyFile /etc/apache2/ssl/server.key
    </VirtualHost>
  14. Enable the subversion virtual host.
    sudo a2ensite svn.example.com
  15. Create user/password combinations.
    sudo htpasswd /var/local/svn/svn.example.com/conf/passwd username
  16. Reload the Web server conf.
    sudo /etc/init.d/apache2 reload

Trac

  1. Create the Web dir.
    sudo mkdir -p /var/local/www/trac/trac.example.com
  2. Set proper permissions.
    sudo chmod 2770 /var/local/www/trac/trac.example.com
  3. Create a Trac instance.
    sudo trac-admin /var/local/www/trac/trac.example.com initenv
  4. Set proper ownership on the Web dir.
    sudo chown -R www-data:example /var/local/www/trac/trac.example.com
  5. Allow the group to write to the repository.
    sudo chmod -R g+w /var/local/www/trac/trac.example.com
  6. Configure it.
    sudo vi /var/local/www/trac/trac.example.com/conf/trac.ini
  7. Create a dir for the log files.
    sudo mkdir /var/log/apache2/trac.example.com
  8. Add the site to the log rotation list.
    sudo vi /etc/logrotate.d/apache2
  9. Configure the virtual host...
    sudo vi /etc/apache2/sites-available/trac.example.com

    # Trac Configuration
    <VirtualHost [server's IP address]:80>
    ServerName trac.example.com
    Redirect / https://trac.example.com/
    </VirtualHost>
    <VirtualHost [server's IP address]:443>
    ServerName trac.example.com
    DocumentRoot /var/local/www/trac/trac.example.com/
    Alias /trac/ /usr/share/trac/htdocs
    <Directory "/usr/share/trac/htdocs/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
    <Location />
    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonInterpreter main_interpreter
    PythonOption TracEnv /var/local/www/trac/trac.example.com/
    PythonOption TracUriRoot /
    AuthType Basic
    AuthName "trac.example.com"
    # Use the SVN password file.
    AuthUserFile /var/local/svn/svn.example.com/conf/passwd
    Require valid-user
    </Location>
    CustomLog /var/log/apache2/trac.example.com/access.log combined
    ErrorLog /var/log/apache2/trac.example.com/error.log
    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/apache.pem
    # Add this once there is a real (non self-signed) certificate.
    # SSLCertificateKeyFile /etc/apache2/ssl/server.key
    </VirtualHost>
  10. Enable the Trac virtual host.
    sudo a2ensite trac.example.com
  11. Configure Trac permissions.
    sudo trac-admin /var/local/www/trac/trac.example.com
  12. Restart the Web server.
    sudo /etc/init.d/apache2 restart

Have fun! :-)