How-To: Set up SVN with Apache2 in Linux (Ubuntu)

Initially I didn’t plan on writing anything up about this, since its pretty basic to setup. But I ran into a slight problem, which I imagine others might run into also. I guess most would have Apache running already, so all that is needed is SVN:

Code:
> apt-get install subversion libapache2-svn

Say you have a domain already set up, call it abc.com. You want to be able to checkout a repository from abc.com/svn.

Open the following file (/etc/apache2/mods-available/dav_svn.conf) in an editor and follow the instructions. In the most basic form (with no authentication) you’ll have something like this when your done:

Code:
< Location /abc.com/svn >
DAV svn
SVNPath /svn
< /Location>

Inside the < Location /abc.com/svn > that path must point to a directory in your web server which does NOT exist. abc.com will exist, but make sure svn doesn’t. The SVNPath will point to the actual repository which MUST be outside your web server space.

This way, if you go to a browser and type: http://www.abc.com/svn nothing will show up, but when you checkout your repository, you will be re-directed to the actual svn directory (in this case /svn).

Now create the SVN repository, in directory /svn

Code:
> svnadmin create /svn

Be sure to change the permissions on this directory, so the web server can write to the folder:

Code:
> chown -R www-data /svn

Restart Apache2:

Code:
> /etc/init.d/apache2 -k restart

Now from a remote computer, you should be able to type:

Code:
svn co http://xxx.xxx.xxx.xx/abc.com/svn < name >

(were xxx.xxx.xxx.xxx is your server ip and name is what you want to call the local folder)

Related Articles:

Follow me on Twitter!

Your Ad Here

10 Responses to “How-To: Set up SVN with Apache2 in Linux (Ubuntu)”

  1. Sam Hassell says:

    Thanks for this how-to, it just came in handy!

    -Sam.

  2. Alp Tilev says:

    great how-to. but does this level of configuration ask for authentication?

  3. Nael says:

    Yo George. This was useful..i didnt know the svn repo had to be outside the webserver. Working great now with authentication :)

  4. wese says:

    Nice howto, short and simple.
    Thanks for sharing.

  5. chris says:

    to add password requirement to do commits..

    DAV svn
    SVNPath /svn

    AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile /etc/apache2/dav_svn.passwd

    Require valid-user

    and in console:

    create the password file


    rm -f /etc/apache2/dav_svn.passwd

    add username and password for some 1 (useing temar as example)

    htpasswd2 -c /etc/apache2/dav_svn.passwd temar

    it will ask for password after u enter that :D
    enjoy

  6. Jagjot Singh says:

    Hi, i just completed my svn installation but i’m not able to browse my project. e.g. svn co http://localhost/svn/myproject gives me doesn’t exist. Where am i going wrong ?

  7. Jiten says:

    Hi, I have installed svn 1.5.4 on unix server. I want to create repository on UNIX server and client on windows. How can I achieve this? Please help me.

  8. George A. Papayiannis says:

    So now you need to get a client going. I use http://tortoisesvn.tigris.org

  9. Pope says:

    Note: ” htpasswd2 -c /etc/apache2/dav_svn.passwd temar ” changed a little while ago slightly. If htpasswd2 does not work, try htpasswd instead:

    thus: htpasswd -c /etc/apache2/dav_svn.passwd temar

  10. Ranjan Yengkhom says:

    I have followed the steps properly. My problem is about authentication user to access svn

    I created a user say test as
    htpasswd -cm /etc/apache2/dav_svn.passwd test

    Then I open the svn :
    http://xxx.xxx.xxx.xx/svn
    I got the login interface. When I try login with USER-ID (test) & correct password
    I get the message:
    You don’t have permission to access /svn/testKRA on this server.

    Can you plz help me what is wrong with my installation process..

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>