How to install and configure subversion on RedHat CentOS systems

Step 1: Install subversion

[[email protected] ~]# yum -y install subversion

Step 2: Create a username under which the subversion daemon will run and set a password for it

sudo yum install subversion

sudo /usr/sbin/useradd svn
sudo passwd svn

su – svn

cd ~
mkdir repositories

cd repositories
svnadmin create myproject

ll myproject
-rw-rw-r– 1 svn svn 229 Nov 21 16:58 README.txt
drwxrwxr-x 2 svn svn 1024 Nov 21 16:58 conf
drwxrwsr-x 6 svn svn 1024 Nov 21 16:58 db
-r–r–r– 1 svn svn 2 Nov 21 16:58 format
drwxrwxr-x 2 svn svn 1024 Nov 21 16:58 hooks
drwxrwxr-x 2 svn svn 1024 Nov 21 16:58 locks

You need to edit “myproject/conf/svnserve.conf” and uncomment the following lines:

auth-access = write
password-db = passwd

and edit the password file “myproject/conf/passwd” adding a new user and password. Note that the password is stored in plain text. In the following example we have a user called “john” whose password is “foobar123”:

john = foobar123

And finally, as the svn user, start the subversion daemon like so:

svnserve -d -r /home/svn/repositories

Connect to svn://[email protected]/myproject

[[email protected] ~]# /usr/sbin/useradd -m -d /home/svn svn
[[email protected] ~]# passwd svn

Step 3: Login as the newly created username

[[email protected] ~]# su - svn
[[email protected] ~]$

Step 4: Create a directory named repositories (where you will create all the subversion projects) and access it

[[email protected] ~]$ mkdir repositories
[[email protected] ~]$ cd repositories

Step 5: Create a project and list the contents of the newly created project (I chose to name mine “coolproject”)

[[email protected] repositories]$ svnadmin create coolproject
[[email protected] repositories]$ ls -lh coolproject/
 total 32K
 drwxrwxr-x 2 svn svn 4.0K Feb 27 17:42 conf
 drwxrwsr-x 6 svn svn 4.0K Feb 27 17:42 db
 -r--r--r-- 1 svn svn    2 Feb 27 17:42 format
 drwxrwxr-x 2 svn svn 4.0K Feb 27 17:42 hooks
 drwxrwxr-x 2 svn svn 4.0K Feb 27 17:42 locks
 -rw-rw-r-- 1 svn svn  229 Feb 27 17:42 README.txt

Step 6: Now it’s needed to enable write access and let subversion know which file is used to store credentials, for this we need to edit coolproject/conf/svnserve.conf and uncomment the following options:

auth-access = write
password-db = passwd
[[email protected] repositories]$ sed -i 's/# auth-access = write/auth-access = write/' coolproject/conf/svnserve.conf
[[email protected] repositories]$ sed -i 's/# password-db = passwd/password-db = passwd/' coolproject/conf/svnserve.conf

Step 7: Add the desired username and password to coolproject/conf/passwd file (make sure you replace yourusername and somepassword with the desired username and password)

[[email protected] repositories]$ echo "yourusername = somepassword" >> coolproject/conf/passwd

Step 8: You can now start the subversion server using the following command

[[email protected] repositories]$ svnserve -d -r /home/svn/repositories

Step 9: If for any reason you want to stop the subversion server (for example you want to create a new project and you need to restart it) use the following command to do so

[[email protected] repositories]$ killall -9 svnserver

Congratulations! You have successfully installed and configured subversion on a RHEL/CentOS system, you may now connect to svn://[email protected]/coolproject and begin working on your project!

3 thoughts on “How to install and configure subversion on RedHat CentOS systems”

  1. Hey there! I just wanted to ask if you ever
    have any problems with hackers? My last blog (wordpress) was hacked and I ended up losing
    a few months of hard work due to no backup.
    Do you have any solutions to prevent hackers?

    • Hi, I had some experience with hackers that managed to gain access to some of my customer’s blogs, but all of them had backups.
      Nowadays it’s mandatory to have a backup system, no matter what – that’s if you care about your site/work. The first thing you need to do is see how they managed to get in, for that you have your webserver’s logs, ftp logs, etc.
      The first thing you should consider is to change the passwords to very strong ones (letters, numbers, symbols, 20 characters minimum) which obviously should not be dictionary based. It’s safer to have a strong password stored on a piece of paper than to have a weak one that you remember.
      Change your admin page url and add a 2nd layer of protection by activating htaccess password protection (you will be required to enter a different username/password before accessing the admin area of your site).
      I suggest switching from shared hosting to a VPS or even a dedicated server where you can set up custom environment, like a read only database for your blog, making your site’s files immutable, etc.
      Also it might be a good idea to allow authenticating/posting only over VPN or from certain IP addresses.

  2. hi…
    good info on subversion setup, above mentioned step work on RHEL 7 with minor fixes.

    1. After user creation basic file required to populated user home directory, also need to add user to wheel group.

    2. require edit of /etc/sysconfig/svnserve file and add the custom home directory where we created svn repository.

    3. fix selinux context with the command : chcon -t unconfined_exec_t $(which svnserve)

    than restart the svn service with the command systemctl restart svnserve.service

    volla… this work for me.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.