Setup Subversion (SVN) Server with Apache on Fedora / CentOS
November 21, 2016Foreword
This tutorial covers installing Subversion (SVN) Server and configuring it to run through Apache on Fedora 24, but these steps will work on any Red Hat Linux distro (Fedora / CentOS / RHEL).
Prerequisites
You will need:
- Fedora 24+
- Sudo or Root Access
Steps
Install Subversion (SVN)
1. Install SVN:
$ sudo dnf install -y mod_dav_svn subversion
Install Apache and Start It
2. Install Apache, enable it to start on boot, and start it immediately:
$ sudo dnf install -y httpd
$ sudo systemctl enable httpd
$ sudo systemctl start httpd
Create an Apache Configuration File for SVN
3. Create a subversion.conf file for Apache:
$ sudo vim /etc/httpd/conf.d/subversion.conf
Paste the following within it:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
DAV svn
SVNPath /var/www/svn/repos
AuthType Basic
AuthName “Subversion repos”
AuthUserFile /etc/svn-auth-conf
Require valid-user
</Location>
Create a Password Authentication File for Accessing SVN
4. Create a .passwd file for each user requiring authentication to the SVN repositories.
For the first user:
$ sudo htpasswd -cm /etc/svn-auth-conf <username>
(enter a password)
For each additional user:
$ htpasswd -m /etc/svn-auth-conf <additional_username>
(enter a password and repeat for all desired users)
Create the SVN Repository
5. Create the SVN repository within a web accessible directory:
$ sudo mkdir -p /var/www/svn
$ cd /var/www/svn
$ sudo svnadmin create repos
Set the ownership to Apache so permissions work:
$ sudo chown -R apache:apache /var/www/svn/repos
Restart Apache
6. Restart Apache to have the SVN configuration file and password authentication take effect:
$ sudo systemctl restart httpd
Verify SVN is Accessible
7. Verify you can access the SVN repository via your browser:
Go to http://<server_ip_or_domain_name>/svn
(Enter the password for the user you created)
Create an SVN Project Directory
8. Create a project directory and its subdirectories/files for your SVN repository:
# cd /tmp
# mkdir testproject
# vi testproject/test.txt
(enter “This is a test” and save the file)
Import the Project into SVN
9. Import the project into the SVN repository:
# svn import /tmp/testproject file:///var/www/svn/repos/testproject -m “Initial import of repository”
Checkout the SVN Repo on Another Machine
10. Checkout your SVN repo on another machine to test that checkouts work:
[user@someothermachine]$ mkdir ~/svn
$ cd ~/svn
$ svn checkout http://<server_ip_or_domain_name>/svn/repos/testproject
Change Security Context to Allow Commits
11. Permit the other machine and/or users to make commits to the SVN repo:
$ sudo chcon -R -t httpd_sys_content_t /var/www/svn/repo
$ sudo chcon -R -t httpd_sys_rw_content_t /var/www/svn/repo