Question

I have a laptop running Ubuntu that I would like to act as a Subversion server. Both for myself to commit to locally, and for others remotely. What are the steps required to get this working? Please include steps to:

  • Get and configure Apache, and necessary modules (I know there are other ways to create a SVN server, but I would like it Apache-specific)
  • Configure a secure way of accessing the server (SSH/HTTPS)
  • Configure a set of authorised users (as in, they must authorised to commit, but are free to browse)
  • Validate the setup with an initial commit (a "Hello world" of sorts)

These steps can involve any mixture of command line or GUI application instructions. If you can, please note where instructions are specific to a particular distribution or version, and where a users' choice of a particular tool can be used instead (say, nano instead of vi).

Was it helpful?

Solution

Steps I've taken to make my laptop a Subversion server. Credit must go to AlephZarro for his directions here. I now have a working SVN server (which has currently only been tested locally).

Specific setup: Kubuntu 8.04 Hardy Heron

Requirements to follow this guide:

  • apt-get package manager program
  • text editor (I use kate)
  • sudo access rights

1: Install Apache HTTP server and required modules:

sudo apt-get install libapache2-svn apache2

The following extra packages will be installed:

apache2-mpm-worker apache2-utils apache2.2-common

2: Enable SSL

sudo a2enmod ssl
sudo kate /etc/apache2/ports.conf

Add or check that the following is in the file:

<IfModule mod_ssl.c>
    Listen 443
</IfModule>

3: Generate an SSL certificate:

sudo apt-get install ssl-cert
sudo mkdir /etc/apache2/ssl
sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem

4: Create virtual host

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/svnserver
sudo kate /etc/apache2/sites-available/svnserver

Change (in ports.conf):

"NameVirtualHost *" to "NameVirtualHost *:443"

and (in svnserver)

<VirtualHost *> to <VirtualHost *:443>

Add, under ServerAdmin (also in file svnserver):

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM

5: Enable the site:

sudo a2ensite svnserver
sudo /etc/init.d/apache2 restart

To overcome warnings:

sudo kate /etc/apache2/apache2.conf

Add:

"ServerName $your_server_name"

6: Adding repository(ies): The following setup assumes we want to host multiple repositories. Run this for creating the first repository:

sudo mkdir /var/svn

REPOS=myFirstRepo
sudo svnadmin create /var/svn/$REPOS
sudo chown -R www-data:www-data /var/svn/$REPOS
sudo chmod -R g+ws /var/svn/$REPOS

6.a. For more repositories: do step 6 again (changing the value of REPOS), skipping the step mkdir /var/svn

7: Add an authenticated user

sudo htpasswd -c -m /etc/apache2/dav_svn.passwd $user_name

8: Enable and configure WebDAV and SVN:

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

Add or uncomment:

<Location /svn>
DAV svn

# for multiple repositories - see comments in file
SVNParentPath /var/svn

AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
SSLRequireSSL
</Location>

9: Restart apache server:

sudo /etc/init.d/apache2 restart

10: Validation:

Fired up a browser:

http://localhost/svn/$REPOS
https://localhost/svn/$REPOS

Both required a username and password. I think uncommenting:

<LimitExcept GET PROPFIND OPTIONS REPORT>

</LimitExcept>

in /etc/apache2/mods-available/dav_svn.conf, would allow anonymous browsing.

The browser shows "Revision 0: /"

Commit something:

svn import --username $user_name anyfile.txt https://localhost/svn/$REPOS/anyfile.txt -m “Testing”

Accept the certificate and enter password. Check out what you've just committed:

svn co --username $user_name https://localhost/svn/$REPOS

Following these steps (assuming I haven't made any error copy/pasting), I had a working SVN repository on my laptop.

OTHER TIPS

Afterwards, I needed to execute (within the context of the example quoted above)

$ sudo chmod g+w /var/svn/$REPOS/db/rep-cache.db

$ sudo chown www-data:www-data /var/svn/$REPOS/db/rep-cache.db

Otherwise I kept receiving a 409 error when committing local modifications (though the commitments were server side effective, I needed to follow up with local updates)

This article seems to give a pretty good rundown of the entire process. I would recommend following the instructions, and then posting some more specific questions about any problems you encouter which aren't addressed in the articles I and other people have linked to in these responses.

If you get 403 forbidden when you hit the webserver it may be because you used a hostname that is not what you specified in your config file (ie localhost or 127.0.0.1). Try hitting https://whateveryousetasyourhostname instead...

Please write a single command on the terminal.

To open the terminal please press Ctrl + Alt + T, and then type this command:

$sudo apt-get install subversion

For Apache:

sudo apt-get -yq install apache2

For SSH:

sudo apt-get -yq install openssh-server

For Subversion:

sudo apt-get -yq install subversion subversion-tools

If you'd like you can combine these into one command like:

sudo apt-get -yq install apache2 openssh-server subversion subversion-tools

I can't help with the rest...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top