Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Setting Up Subversion Version Control in Ubuntu

· 4 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can set up Subversion (SVN) version control on Ubuntu in about 15 minutes. This guide walks you through installing the server, creating a repository, and connecting to it from your own machine. You'll need a Ubuntu system (20.04 or newer) with sudo access and an internet connection.

What You'll Need

  • A Ubuntu computer (physical or virtual) with sudo privileges.
  • Internet access to install packages.
  • Basic comfort with the terminal.

Step-by-Step

  1. Update your system – Open a terminal and run:
    sudo apt update && sudo apt upgrade -y
  2. Install Subversion – Install the server and client packages:
    sudo apt install subversion apache2 libapache2-mod-svn -y
    This installs SVN plus Apache, which we'll use to serve repositories over HTTP.
  3. Create a repository directory – Choose a location, e.g., /var/svn:
    sudo mkdir -p /var/svn
  4. Create your first repository – For example, a project called myproject:
    sudo svnadmin create /var/svn/myproject
  5. Set permissions – Allow the Apache user (www-data) to access the repository:
    sudo chown -R www-data:www-data /var/svn
  6. Configure Apache – Edit the SVN configuration file:
    sudo nano /etc/apache2/mods-available/dav_svn.conf
    Uncomment or add the following lines (labels may vary slightly by Ubuntu version):
    <Location /svn>
      DAV svn
      SVNParentPath /var/svn
      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /etc/apache2/dav_svn.passwd
      Require valid-user
    </Location>

    Save and exit.
  7. Create a password file – Add a user (e.g., alice):
    sudo htpasswd -cm /etc/apache2/dav_svn.passwd alice
    You'll be prompted to set a password. For additional users, use -m instead of -c to avoid overwriting.
  8. Enable required Apache modules – Run:
    sudo a2enmod dav dav_svn auth_basic
  9. Restart Apache – Apply the changes:
    sudo systemctl restart apache2
  10. Test the connection – Browse to http://localhost/svn/myproject in a web browser. You'll be asked for the username and password you created. If you see a listing (even empty), it works.
  11. Checkout your repository – On your local machine (or the same machine), run:
    svn checkout http://localhost/svn/myproject --username alice
    Enter your password when prompted.

Common Mistakes

  • Forgetting to set permissions – If Apache can't read/write the repository, you'll get 403 or 500 errors. Always run chown as in Step 5.
  • Using the wrong URL – The URL must match the Location directive. If you set /svn as the location, the URL is http://server/svn/repo-name.
  • Not enabling modules – Without dav_svn, Apache won't recognize the SVN directives.
  • Creating the password file with the wrong flags – Using -c for every user overwrites the file, deleting all previous users.

Tips

  • Use HTTPS – For production, set up an SSL certificate (e.g., Let's Encrypt) to encrypt passwords in transit.
  • Back up your repositories – Regularly copy the /var/svn directory or use svnadmin hotcopy to a safe location.
  • Create a standard layout – Inside each repository, create trunk, branches, and tags folders to keep things organized: svn mkdir -m "Initial layout" http://localhost/svn/myproject/trunk http://localhost/svn/myproject/branches http://localhost/svn/myproject/tags
  • Use hooks for automation – SVN hooks (e.g., post-commit) can send emails or trigger builds. Check the hooks directory in your repository.

Troubleshooting

If you get a 403 Forbidden error: Check that the Require valid-user line is present and the password file path is correct. Also verify permissions on the repository directory.

If you get a 500 Internal Server Error: Look at Apache's error log: sudo tail -f /var/log/apache2/error.log. Common causes include missing modules or incorrect SVNParentPath.

If checkout fails with authentication prompt repeating: Ensure the password file is readable by Apache and that you used the correct username.

If you can't connect from another computer: Check your firewall: sudo ufw allow 'Apache Full' or allow port 80/443.

If the repository appears empty after checkout: That's normal for a new repo. Add files with svn add and svn commit.

If you need to reset a forgotten password: Re-run htpasswd for that user: sudo htpasswd /etc/apache2/dav_svn.passwd alice and enter a new password.

Frequently Asked Questions

Can I use SVN without Apache?

Yes, you can use svnserve (a standalone server) or access repositories over SSH. Apache is just one option, but it's convenient for web access.

How do I add more users?

Use sudo htpasswd -m /etc/apache2/dav_svn.passwd username (without -c to avoid overwriting).

Can I access the repository from Windows or macOS?

Yes, SVN clients like TortoiseSVN (Windows) or the built-in svn command on macOS work with the same URL.

How do I back up my repository?

Use svnadmin hotcopy /var/svn/myproject /backup/myproject or simply copy the directory while no commits are happening.

What's the difference between SVN and Git?

SVN is centralized (one server), while Git is distributed (each user has a full copy). SVN is simpler for small teams but Git is more popular for modern projects.

Can I host multiple repositories?

Yes, with SVNParentPath pointing to a directory containing multiple repos. Create each with svnadmin create and access them at http://server/svn/repo1, http://server/svn/repo2, etc.