Create SVN Repository in Ubuntu & Access via HTTP


Requirements:

Assuming, you’ve Apache server installed already.

1. Install SVN

Open a terminal & type:

sudo apt-get install subversion

2. Create Repo

Let’s say, we want to create a repo in /var/svn/myrepo. Type in terminal:

cd /var
sudo mkdir svn
sudo svnadmin create /var/svn/myrepo

3. Users & Groups

Create a user & group named “svn”:

sudo adduser svn

Add user “www-data” to “svn” group:

sudo usermod -a -G svn www-data
sudo chown -R www-data:svn /var/svn/myrepo # Run this twice
sudo chmod -R g+rws /var/svn/myrepo # Run this twice

4.  Configure Apache2

Run in terminal:

sudo apt-get install libapache2-svn

You’ll find a file in /etc/apache2/sites-enabled folder. Let’s say, this file is “000-default” (in most cases) – edit this file by typing:

gksudo gedit /etc/apache2/sites-enabled/000-default

Add following lines in the beginning of the file:

    <Location /svn/myrepo>
      DAV svn
      SVNPath /var/svn/myrepo

      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /etc/apache2/passwords
      Require valid-user

    </Location>

Save the file, then restart apache:

sudo /etc/init.d/apache2 restart

5. Adding Users

Then Add the first user typing:

sudo htpasswd -cb /etc/apache2/passwords user1 password-for-user

# Add more users...

sudo htpasswd -b /etc/apache2/passwords user2 password-for-user

Finally, you’ll be able to access your repo at:

http://<ip-of-your-machine>/svn/myrepo

Instead of <ip-of-your-machine> you can also use your computer’s name.

References:

http://www.subversionary.org/howto/setting-up-a-subversion-server-on-ubuntu-gutsy-gibbon-server

https://help.ubuntu.com/community/Subversion

Advertisements

One thought on “Create SVN Repository in Ubuntu & Access via HTTP

Comments are closed.