Install SVN Server on Fedora 31/30, CentOS/RHEL 8.0/7.7
Table of Contents
This is guide, howto install SVN (Subversion) server on Fedora 31/30/29/28, CentOS 8.0/7.7/6.10, Red Hat (RHEL) 8.0/7.7/6.10.
What is SVN (Subversion)?⌗
Subversion is a free/open-source version control system. Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine”.
Install SVN (Subversion) Server on Fedora 31/30/29/28, CentOS 8.0/7.7/6.10, Red Hat (RHEL) 8.0/7.7/6.10⌗
1. Change root user⌗
su -
## OR ##
sudo -i
2. Install needed packages (mod_dav_svn and subversion)⌗
Fedora 31/30/29/28
dnf install mod_dav_svn subversion
CentOS 8.0
dnf install mod_dav_svn subversion
CentOS / Red Hat (RHEL) 7.6/6.10
yum install mod_dav_svn subversion
Note: If you don’t have Apache installed already, this command installs it also. Read more about installing and configuring Apache and PHP >>
3. Modify / Create Subversion config file /etc/httpd/conf.d/subversion.conf⌗
Add following config to /etc/httpd/conf.d/subversion.conf file:
Fedora 31/30/29/28 and CentOS/Red Hat (RHEL) 8.0/7.7⌗
<Location /svn>
DAV svn
SVNParentPath /var/www/svn
# Limit write permission to list of valid users.
<LimitExcept GET PROPFIND OPTIONS REPORT>
# Require SSL connection for password protection.
# SSLRequireSSL
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile /etc/svn-auth-users
Require valid-user
</LimitExcept>
</Location>
LoadModule commands should be in /etc/httpd/conf.modules.d/10-subversion.conf file:
Read more SVN Access Control >>
CentOS/Red Hat (RHEL) 6.10⌗
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
DAV svn
SVNParentPath /var/www/svn
# Limit write permission to list of valid users.
<LimitExcept GET PROPFIND OPTIONS REPORT>
# Require SSL connection for password protection.
# SSLRequireSSL
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile /etc/svn-auth-users
Require valid-user
</LimitExcept>
</Location>
Read more SVN Access Control >>
4. Add SVN (Subversion) users⌗
Use following command:
## Create testuser ##
htpasswd -cm /etc/svn-auth-users testuser
New password:
Re-type new password:
Adding password for user testuser
## Create testuser2 ##
htpasswd -m /etc/svn-auth-users testuser2
New password:
Re-type new password:
Adding password for user testuser2
Note: Use exactly same file and path name as used on subversion.conf file. This example use /etc/svn-auth-users file.
Read more SVN Access Control >>
5. Create and configure SVN repository⌗
mkdir /var/www/svn
cd /var/www/svn
svnadmin create testrepo
chown -R apache.apache testrepo
## If you have SELinux enabled (you can check it with "sestatus" command) ##
## then change SELinux security context with chcon command ##
chcon -R -t httpd_sys_content_t /var/www/svn/testrepo
## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo
Restart Apache:⌗
## Fedora 30/29/28 and CentOS/Red Hat (RHEL) 7.6 ##
systemctl restart httpd.service
## CentOS/Red Hat (RHEL) 6.10 ##
service httpd restart
## OR ##
/etc/init.d/httpd restart
Goto http://localhost/svn/testrepo address and you should see something like following, write username and password:
6. Configure repository⌗
To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:
## Disable anonymous access ##
anon-access = none
## Enable access control ##
authz-db = authz
7. Create trunk, branches and tags structure under testrepo⌗
Create “template” directories with following command:
mkdir -p /tmp/svn-structure-template/{trunk,branches,tags}
Then import template to project repository using “svn import” command:
svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Adding /tmp/svn-structure-template/trunk
Adding /tmp/svn-structure-template/branches
Adding /tmp/svn-structure-template/tags
Committed revision 1.
Check results on browser and see testrepo revision 1:
Read more about SVN (Subversion) Access Control with Apache and mod_authz_svn.
Remember also take regular backups. Here is guide howto backup and restore SVN (Subversion) Repositories.