Status: Deprecated
This article, “Install and configure SVN WebDAV server on a CentOS 6 VPS” covers a version of CentOS 6 that reached end of life (EOL) on November 30th, 2020, and is no longer supported. For this reason, this guide is no longer maintained. If you are currently operating a server running CentOS 6, we highly recommend that you contact RoseHosting fully managed support to upgrade or migrate to a supported version of CentOS for you.
This how-to looks at how to install and configure a SVN (subversion) WebDAV accessible repository server using Apache and a CentOS VPS. What is SVN? It is an open-source centralized version control system, which can track and store the history of files and directories in its repositories with the ability to examine the history of how the data changed and if needed to recover some older versions of the data.
For this tutorial we are using a CentOS 6 based VPS, but the installation and configuration of a SVN repository server accessible via HTTP using the WebDAV protocol is almost the same on any other Linux based VPS.
1. Assuming you have ‘root’ privileges, execute the following command in order to fully update your system and to install the needed packages.
# yum -y update && yum -y install mod_dav_svn subversion
Next, we’re going to create and configure the subversion users and repositories.
2. To create the initial svn user use the following command:
# htpasswd -cm /etc/svn_htpasswd user1
it will create the user ‘user1’ and will create the ‘/etc/svn_htpasswd’ file which will hold the svn usernames along with their encrypted passwords.
(to create additional svn users you need to omit htpasswd’s ‘-c’ switch, for example:
# htpasswd -m /etc/svn_htpasswd user2
3. Next, create the repositories using the following commands:
# mkdir /var/www/repos # svnadmin create /var/www/repos/test_repo1 # svnadmin create /var/www/repos/test_repo2 # chown -R apache: /var/www/repos/
In order to have the repositories accessible via HTTP, we need to configure the subversion apache configuration file.
4. Create or modify subversion’s configuration file ‘/etc/httpd/conf.d/subversion.conf’ as follows:
# cat /etc/httpd/conf.d/subversion.conf LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so <Location /repos> DAV svn SVNParentPath /var/www/repos AuthType Basic AuthName "Subversion repositories" AuthUserFile /etc/svn_htpasswd Require valid-user AuthzSVNAccessFile /etc/svn_acl </Location>
next restart the apache webserver, so the changes can take effect. Issue the following command to reload apache:
# service httpd restart
(if you get something like this: ‘mod_dav_svn.so: undefined symbol: dav_register_provider’, then most likely you need to activate the ‘mod_dav.so‘ and ‘mod_dav_fs.so‘ apache modules in its core configuration file ‘/etc/httpd/conf/httpd.conf’)
5. Disable anonymous access to the repository and enable ACL (access control list) instead. To do this add the following two lines to the repo’s ‘svnserve.conf‘ configuration file:
# cat /var/www/repos/test_repo1/conf/svnserve.conf [general] [sasl] ## Disable anonymous access ## anon-access = none ## Enable access control ## authz-db = authz
6. Create the SVN access list, so we can assign different access levels to the users. For example:
# cat /etc/svn_acl [groups] group1 = user1 group2 = user2 group3 = user3, user4 [/] * = r @group1 = rw user1 = rw [test_repo1:/] @group1 = rw @group2 = [test_repo1:/static] @group2 = r [test_repo2:/public] @group3 = rw user2 = r
7. Finally, create ‘static’, ‘documentation’ and ‘code’ repository structure under the ‘test_repo1’ repository.
Create ‘template’ directories with following command:
# mkdir -p /tmp/test_repo1/{code,static,documentation}
once they’re created you can import the directories into the ‘test_repo1’ repository by executing the following command:
# svn import -m 'Testing ...' /tmp/test_repo1/ http://yourdomain.tld/repos/test_repo1/
Now you can access the newly created SVN repository via HTTP protocol at ‘http://yourdomain.tld/repos/test_repo1/’. An authorization window will popup where you have to login with the appropriate svn user.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
In your svnserve.conf you point to the authz in the local dir and not to the authz in the /etc.. Is that a mistake or am I missing something?
Thanks
Since the repositories are accessed via apache mod_dav, the configuration file in /etc/svn_acl is used. the authz in the local directory isn’t used in this case.
when i try this command cat /etc/svn_acl . its says no such file or directory . what can i do now
You need to create a SVN access list file (/etc/svn_acl), so you can assign different access levels to your users. Please read the step 6 of this tutorial for more information on this.