Turnleaf Design Ramblings of a junior developer

4Aug/100

Setting up SVN over http on Linux

One project I was planning on starting before I went on my extended hiatus was setting up a development environment, so it only seems natural that I start there again. I already went over how to setup a SVN repository, however in that example I used VisualSVN which require elements of Visual Studio and since I primarily focus on Java development, VisualSVN isn't a particularly good choice. So today I will go over how to setup a svn server in Linux (Ubuntu 10.04 to be exact).

Getting everything we need

From the terminal run the following command to get all the different packages we will need:

sudo apt-get install apache2 subversion subversion-tools libapache2-svn

Creating a repository

So everything is now downloaded and installed (wasn't that easy?!), let's get subversion setup.

First lets create a new folder to hold our repository.

sudo mkdir /repos

Now create an actual svn repository

sudo svnadmin create /repos

And just like that we have a svn repository. But we are not near done yet. You can look around in repos if you want, however we will be letting Apache handle the authorization and authentication so there is not much here for us.

Accessing subversion over http

Since most code shops don't have everybody working on one computer, to really make svn useful we need it accessible over http, something that apache does very well. So let's get started.

At the bottom of (/etc/apache2/)apache2.conf add the following:

<Location /repos>
DAV svn
SVNPath /repos
AuthType Basic
AuthName “SVN Repository”
AuthUserFile security/svnpasswd
Require valid-user
</Location>

Make sure you are currently in your /etc/apache2 directory and run the following command:

sudo mkdir security

Navigate to the newly created security directory and run the following command:

sudo htpasswd -c svnpasswd [username]

You will then be prompted to enter (and reenter) a new password for the user. This will be the user you use to login into svn. If you want to add addition users drop the “-c” (which creates/overwrites a file). You can also add the password directly if need ([username] [password]) however, for security reasons, this is not recommended.

Setting up Permissions

We are getting closer, you should be able to navigate to the repository, however you will likely be getting a 500 error when you login. These errors are related to incorrect permissions settings so let's fix that.

Run the following command:

sudo useradd -U www

This will create the group “www” with the user “www.”

In httpd.conf add the following lines:

User www
Group www

This will specify the user and group that Apache will use

Finally go back to the root directory and run the following:

chown -R www:www repos

Be sure to navigate into your repos directory and run the following command (otherwise the command will be run against your entire file system [the -R means recursive]):

sudo chmod -R /repos 764 *

These last two commands put the the www user and group in control of the svn repo along with giving the proper permissions to read/write/execute. And just like that you have fully operational svn server accessible over http! Pretty sweet eh?

If you are still unable to access and/or update the repository check the apache error.log located under /var/logs/apache2. If you still cannot figure it out ask and I shall try to answer.

This tutorial is merely the beginning, for (much) more information on how to configure your svn server go here.

Sources:
http://www.section6.net/wiki/index.php/Setting_up_Subversion_in_Linux
http://blogs.usask.ca/slb534/

Tested and verified on Ubuntu 10.04

Bookmark and Share

Technorati Tags: ,

Related posts:

  1. Taming of the Subversion, a SVN primer; part 1
  2. Taming of the Subversion, a SVN primer; part 2
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.