Host your own open source project on Ubuntu in just 3 easy steps!

This is a zero-commentary guide to getting Apache 2, Subversion, and Trac all up and running with SSL on Ubuntu.

If you’re looking for more explanation of what each command does, please skip down to the references at the end of the post. If, on the other hand, you’re looking to get your open source project up and running fast without having to think too hard, you’ve come to the right place.

Note: I’ve tested this process on Ubuntu’s Gutsy Gibbon, v7.10.

1) Install Apache 2 with SSL

sudo apt-get install apache2 ssl-cert
sudo a2enmod ssl
sudo mkdir /etc/apache2/ssl
sudo /usr/sbin/make-ssl-cert \
     /usr/share/ssl-cert/ssleay.cnf \
     /etc/apache2/ssl/apache.pem
sudo cp /etc/apache2/sites-available/default \
     /etc/apache2/sites-available/ssl

Edit:

sudo vi /etc/apache2/sites-available/ssl

Replace:

NameVirtualHost *
<VirtualHost *>

With:

NameVirtualHost *:443
<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.pem
        SSLProtocol all
        SSLCipherSuite HIGH:MEDIUM
sudo a2ensite ssl

Edit:

sudo vi /etc/apache2/apache2.conf

Add:

ServerName servername

2) Install Subversion

sudo apt-get install subversion libapache2-svn
sudo mkdir /var/svn
cd /var/svn
sudo mkdir project
sudo svnadmin create /var/svn/project
sudo svn mkdir file:///var/svn/project/trunk -m trunk
sudo svn mkdir file:///var/svn/project/tags -m tags
sudo svn mkdir file:///var/svn/project/branches -m branches
sudo chown -R www-data.www-data project
sudo chmod -R g+rws project
sudo htpasswd -c /etc/subversion/passwd user_name

Edit:

sudo vi /etc/apache2/mods-available/dav_svn.conf

Add:

<Location /svn>
   DAV svn
   SVNParentPath /var/svn
   AuthType Basic
   AuthName "Subversion"
   AuthUserFile /etc/subversion/passwd
   SSLRequireSSL
   <LimitExcept GET PROPFIND OPTIONS REPORT>
      Require valid-user
   </LimitExcept>
</Location>

3) Install Trac

sudo apt-get install trac \
                     libapache2-mod-python \
                     python-setuptools
sudo mkdir /var/trac
cd /var/trac
sudo trac-admin project initenv
sudo trac-admin project permission add user_name TRAC_ADMIN
sudo chown -R www-data.www-data /var/trac

Edit:

sudo vi /etc/apache2/sites-available/ssl

Add to bottom:

<LocationMatch "/trac/[[:alnum:]]+/login">
    AuthType Basic
    AuthName "trac"
    AuthUserFile /etc/subversion/passwd
    Require valid-user
    SSLRequireSSL
</LocationMatch>

<Location /trac>
   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnvParentDir /var/trac
   PythonOption TracUriRoot /trac
   SSLRequireSSL
</Location>
sudo /etc/init.d/apache2 restart

References

Feel free to if you found this useful.