Fork me on GitHub

Installing Subversion on a Home Ubuntu Server - Setup Log Files

Article Index

10. Setup the log files

First, create a directory for the logs. These should go with the Apache logs since we will be using Apache to access the repository.

sudo mkdir /var/log/apache2/

Next, add the log directory to the log rotate script.

sudo vi /etc/logrotate.d/apache2

Add the following lines to the file:

/var/log/apache2/*.log {
rotate 52

11. Generate a self-signed server key/certificate for Apache

If you have not yet generated a self-signed certificate, you need to do this for the SSL to work. Since you probably don't have a dedicated IP address for your home server, and you're more than likely to be using this for personal use, I assume you're not going to want to pay for an SSL certificate.

Although you will recieve a warning when you visit your repository through a web browser when using a self-signed certificate, it will still be an encrypted connection. That means your password won't be transmitted in plain text through the internet for everyone to grab. This is good.

If you aren't sure if you already have a certificate on you system, check for the directory /etc/apache2/ssl and look for a file called apache.pem. If you don't find it, you probably need to generate one. Granted, yours could be in a different location, but it won't hurt to have this one on the system if it is.

To generate the certificate enter the following commands (the second command which begins sudo openssl and ends apache.pem should go on a single line):

sudo mkdir /etc/apache2/ssl
sudo openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem -keyout /etc/apache2/ssl/apache.pem

You will be asked a series of questions. Answer them to the best of your ability. There is only one that you should pay special attention to, the one that asks for Common Name (CN). You should enter than name of your server for that question. If you are unsure what the name of your server is, type the following command and make note of the output before you issue the openssl command:


Once you finish answering the questions, your certificate will be on the server.

12. Add the virtual host definition and configure Apache

For this tutorial, we'll assume the server is at internal IP address You now need to choose a port number for your subversion repository.

Generally, since you are using SSL to access the server, you would put the repository on port 443. However, most residential ISPs block all incoming ports less than 1024, so we need to pick a different port. Personally, I chose 8088. You are welcome to choose whatever you like.

First, to make sure that apache will be listening on that port, you need to edit the ports configuration:

sudo vi /etc/apache2/ports.conf

Add the following line directly below the line Listen 443, replacing 8088 with the port number that you chose:

Listen 8088

Next, you need to create the Virtual Host file:

sudo vi /etc/apache2/sites-available/

The following text should go in the Virtual Host file, replacing the IP address with your server IP address and the port number with the port that you chose:

<Location />
DAV svn

SVNPath /usr/local/svn/

AuthType Basic
AuthName ""
AuthUserFile /usr/local/svn/
AuthzSVNAccessFile /usr/local/svn/

Require valid-user
CustomLog /var/log/apache2/ combined
ErrorLog /var/log/apache2/
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 *>
Redirect /
LogLevel warn
CustomLog /var/log/apache2/ combined
ErrorLog /var/log/apache2/

13. Enable the site and restart Apache

Before Apache will recognize the site and include it in the configuration, you must enable the site using the a2ensite command:

sudo a2ensite

Now you must restart Apache for the changes to take effect:

sudo /etc/init.d/apache2 restart