How to setup svn repository on AWS Ubuntu Linux with apache simple auth

Svn (Subversion) is one of the popular options for maintaining source code versions and revisions on Linux. Here are the steps to install and setup svn repository on Ubuntu Linux with Apache web simple auth.

  1. First install subversion main package and apache subversion module
    sudo apt-get install subversion
    sudo apt-get install libapache2-svn
  2. Create a test directory and a file to import into repository. This step can be skipped if you want empty repository.
    mkdir mytestproj
    vi mytestproj/README.txt (with some text)
  3. Create a home for repositories and create a repository named repo1.
    sudo mkdir /svn
    sudo chown www-data:www-data /svn
    sudo -u www-data mkdir /svn/repos/
    sudo -u www-data svnadmin create /svn/repos/repo1

    Here we are making all directories owned by www-data as apache runs as user www-data and should be able to write in these directories.

  4. Import the test directory into the repository repo1. You can skip this step if you want an empty repository.
    sudo -u www-data svn import -m "mytestproj import" mytestproj file:///svn/repos/repo1/mytestproj
  5. Look at the sample conf file at (/etc/apache2/mods-available/dav_svn.conf). Create your own apache conf file (e.g. /etc/apache/conf.d/my_svn.conf) with the following configuration:
    <VirtualHost *:80>
      <Location /repos>
        DAV svn
        SVNListParentPath on
        SVNParentPath /svn/repos/
        AuthType Basic
        AuthName "Authorization Realm"
        AuthUserFile /etc/auth-file-svn
        Require valid-user

    Replace with the appropriate host name. Also make sure that DNS entry exists.

  6. Create /etc/auth-file-svn using htpasswd
    sudo htpasswd -c /etc/auth-file-svn [username]

    The username should be desired username for svn checkins. The htpasswd command will ask you for password. The option -c is only needed for first user creation as it will create the file /etc/auth-file-svn.

  7. Restart apache using sudo service apache2 restart and access You should see the list of repositories as shown below.
    sample-svn-repo-list Now click on repo1 repository. This corresponding url is Here is how it should look:
  8. To checkout the repository repo1 you can use the following command:
    svn co


Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments