How to setup SVN server on ubuntu 14.04

SVN (Subversion) is an opensource version control system. it is used to store previous changes of your project files like documentation, coding etc. also you can track and identify who made the particular changes in the project files . Here in this article we can see how to setup SVN server on ubuntu 14.04 .

Setup SVN server on ubuntu 14.04

Let’s start the installation .
Step 1 » Issue the below command to update the repositories.
sudo apt-get update
Step 2 » After updating repositories , Issue the below command to install SVN and apache webserver (To access SVN through http ) .
sudo apt-get install subversion apache2 libapache2-svn apache2-utils
Step 3 » Now create a directory and create a new repository in that directory ( Here i’m using testrepo as repository name ).
sudo mkdir -p /svn/repos/
sudo svnadmin create /svn/repos/testrepo

Step 4 » Now change ownership for the repository.
sudo chown -R www-data:www-data /svn/repos/testrepo
Step 5 » Create a file testrepo.conf in /etc/apache2/sites-available/ and add the below lines for creating apache virtual host.

<Location /svn>
  DAV svn
  SVNParentPath /svn/repos/
  AuthType Basic
  AuthName "Test Repo"
  AuthUserFile /etc/svnpasswd
  Require valid-user
 </Location>

SVNParentPath /svn/repos/ : Parent Directory without repository name.
AuthUserFile /etc/svnpasswd : File need to be created ( Step 8) for user details.

Step 6 » Issue the below command to enable the Site ( testrepo in the below command should match the file name created in the previous step )
sudo a2ensite testrepo
Step 7 » Now restart or reload apache service.
sudo service apache2 reload
Step 8 » Issue the command to create user for accessing repository and add the user details to /etc/svnpasswd file.
Use this command to create first user.
sudo htpasswd -cm /etc/svnpasswd user1
Use the same command without c option to create additional users.
sudo htpasswd -m /etc/svnpasswd user2
Step 9 » Now you can access http://yourip/svn/testrepo in your browser ( Eg http://10.0.1.15/svn/testrepo ) and you can see the page like below after successful authentication.
Setup svn server ubuntu 14.04
That’t it , your server is ready.
You could use svn clients such as Tortoisesvn on windows and Rapidsvn on ubuntu for commiting and updating repository.
good luck

37 Comments

  1. what does this error mean?

    sudo service apache2 reload

    * Reloading web server apache2 *

    * The apache2 configtest failed. Not doing anything.

    Output of config test was:

    AH00526: Syntax error on line 34 of /etc/apache2/sites-enabled/anusha.conf:

    ServerAlias only used in

    Action ‘configtest’ failed.

    The Apache error log may have more information.

  2. what does this error mean?

    sudo service apache2 reload

    * Reloading web server apache2 *

    * The apache2 configtest failed. Not doing anything.

    Output of config test was:

    AH00526: Syntax error on line 34 of /etc/apache2/sites-enabled/anusha.conf:

    ServerAlias only used in

    Action ‘configtest’ failed.

    The Apache error log may have more information.

  3. Hi
    created testrepo.conf in /etc/apache2/sites-available/
    now i dun wan it any more and as i deleted testrepo.conf
    and restart apache it gives error at
    apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/testrepo.conf: No such file or directory

    so just to restart apache created enpty testrepo.conf

    but looking for proper solution if dun needs testrepo and testrepo.conf any more so wat to do

  4. Hi
    created testrepo.conf in /etc/apache2/sites-available/
    now i dun wan it any more and as i deleted testrepo.conf
    and restart apache it gives error at
    apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/testrepo.conf: No such file or directory

    so just to restart apache created enpty testrepo.conf

    but looking for proper solution if dun needs testrepo and testrepo.conf any more so wat to do

    • I got the same issue and here’s the way to solve, just run following command to disable repository on apache
      sudo a2dissite testrepo.conf

  5. * sudo a2ensite testrepo.conf
    (the .conf) might be important 🙂
    *sudo service apache2 restart might be needed instead of reload…

    Thanks for the article!

    P.S. delete the article below … virtualhost was not needed..

  6. Hello,
    it looks like that its quite important that the repository’s parent folder (/svn/ in this case) is located on the top of the linux filesystem hirarchy ( / ).
    After installing the server following the instructions in this article, I had a problem with the permissions of the parent folders of the “repos” folder and the problem was that if the svn folder is not on top of the filesystem (/svn/) then all of its parent folders would also have to be owned by www-data.

    Maybe this helps if someone finds the same solution in google like me for that error and then is not sure if its right or right.
    For me t worked.
    I created the svn folder in /svn/ in my linux machine and it worked.

  7. Hello,
    it looks like that its quite important that the repository’s parent folder (/svn/ in this case) is located on the top of the linux filesystem hirarchy ( / ).
    After installing the server following the instructions in this article, I had a problem with the permissions of the parent folders of the “repos” folder and the problem was that if the svn folder is not on top of the filesystem (/svn/) then all of its parent folders would also have to be owned by www-data.

    Maybe this helps if someone finds the same solution in google like me for that error and then is not sure if its right or right.
    For me t worked.
    I created the svn folder in /svn/ in my linux machine and it worked.

  8. Great article! Just wanted to ask: I have followed this exactly and seems to have everything configured correctly except for I get the following error below when trying to access via browser, I can login, but it say the message below:

    This XML file does not appear to have any style information associated with it. The document tree is shown below.

    Could not open the requested SVN filesystem

    Any help given would be greatly appreciated…might be simple fix..but will be much appreciated!

  9. Hello guys, i’ve just configured SVN using this tutorial. I can checkout repo but i can not commit any changes. Clients using Tortoise SVN on Windows, SVN server is on Ubuntu 14.04.

    Error during commit is:
    “Can’t open file ‘/svn/repos/testrepo/db/txn-current-lock’: Permission denied”

    Any advices what can I do?

  10. I am getting this error all the time . . . .

    root@svn-new:/etc/apache2/sites-available# service apache2 reload
    * Reloading web server apache2
    *
    * The apache2 configtest failed. Not doing anything.
    Output of config test was:
    AH00526: Syntax error on line 2 of /etc/apache2/sites-enabled/testrepo.conf:
    Invalid command ‘xc2xa0xc2xa0DAV’, perhaps misspelled or defined by a module not included in the server confi
    guration
    Action ‘configtest’ failed.
    The Apache error log may have more information.

    • just run the following command ,the problem is that the module that need by the svn in not loded in apache so use the following command and check it
      #apt-get install subversion apache2 libapache2-svn apache2-utils

  11. Hi, i know this is quite old, but I get a Problem on this:
    If i call my site and my repo:

    Not Found
    The requested URL /testrepo was not found on this server.

    Apache/2.4.7 (Ubuntu) Server at IP.IP.IP.IP Port 80

  12. Thanks alot!! I just want to add please change your testrepo.conf configuration because it shows “&-l-t;Location /svn&-g-t;” & ” &-l-t;/Location&-g-t;” which must be “” & ” ” it will help alot of noobs like me Thanks!
    UPDATE: I guess it is the problem of different OS but still take a look

  13. ug 06 09:30:09 VM apache2[28029]: * The apache2 configtest failed. Not doing anything.
    Aug 06 09:30:09 VM apache2[28029]: Output of config test was:
    Aug 06 09:30:09 VM apache2[28029]: AH00526: Syntax error on line 2 of /etc/apache2/sites-enabled/testrepo.conf:
    Aug 06 09:30:09 VM apache2[28029]: Invalid command ‘DAV’, perhaps misspelled or defined by a module not included in the server
    Aug 06 09:30:09 VM apache2[28029]: Action ‘configtest’ failed.
    Aug 06 09:30:09 VM apache2[28029]: The Apache error log may have more information.
    Aug 06 09:30:09 VM systemd[1]: apache2.service: Control process exited, code=exited status=1
    Aug 06 09:30:09 VM systemd[1]: Reload failed for LSB: Apache2 web server.

    Get this error

  14. the tuto is verry good and easy. if you have any problem is it depend of the settiings of your apache server you cann try to autoremouve and reinstall it or if you have a new Server like me you can reinstall another system in your server to mouve all Ubuntu-settings and reinstall ubuntu it will work!

  15. Seems incomplete…No instructions on how to add this to Upstart? Must be why, a year later, I’m trying to figure out how to setup SVN with upstart!

Leave a Reply

Your email address will not be published.


*