Main menu

Configure Apache SVN on CentOS

Apache Subversion also know as SVN is an versioning and revision control system. It’s an free software comes under Apache License. It’s works as an module under popular web server Apache HTTP. Let’s Configure Apache SVN on CentOS

You need to install mod_dev_svn as an HTTP server.

# yum install httpd subversion mod_dav_svn

Configure Apache SVN on CentOS

With this configuration we are loading the SVN module in Apache, creating a parent directory for repositories and using a basic authentication for our clients.

# vi /etc/httpd/conf.modules.d/subversion.conf
# Loading the required modules in Apache
LoadModule dav_svn_module       modules/mod_dav_svn.so
LoadModule authz_svn_module     modules/mod_authz_svn.so
Alias /svn /var/www/svn
<Location /svn>
  DAV svn
  SVNParentPath  /var/www/svn
  SVNListParentPath on
  SVNAutoVersioning on
  AuthName "Enterprise Shared Repository"
  AuthType Basic
  AuthUserFile /root/.svnpasswd
  Require valid-user
  satisfy all
  Order allow,deny
  Allow from all
</Location>

 Understanding the configuration

DAV svn : Tells Apache to use SVN module to handle all request
SVNParentPath : Location in the file system where all sub-directories are repositories.
SVNListParentPath : List all repository of parent.
SVNAutoVersioning : WebDAV clients to result in automatic commits.
AuthName: Authentication name for SVN repository.
AuthType: What type of authentication will be used like basic or digest.
AuthUserFile: Users and password file used for authentication.
satisfy all: Allow request if authorization and authentications are met.
Order allow,deny : Sequence of authorization.
More information can be found here

Configuring the Authentication

Create a password file and a user with htpasswd command.

# htpasswd -c /root/.svnpasswd user1
# htpasswd /root/.svnpasswd user2

Note: -c option is used for creating password file so it must be used only once.

Creating the repository

Let’s create the necessary directory and our first repository with svnadmin command. svnadmin command is provided by subversion package.

# mkdir /var/www/svn
# cd /var/www/svn/
# svnadmin create myrepo01
# chown -R apache.apache myrepo01/

Checking the repository from your browser

http://<your_ip>/svn

Note: If it’s not working might be the default selinux policy is blocking them, disbale selinux for temporary and recheck if it’s working.

# setenforce 0

If everything works set the selinux context  to provide necessary permissions.

# chcon -R -t httpd_sys_content_t /var/www/svn/
# chcon -R -t httpd_sys_rw_content_t /var/www/svn/

Working with command line with Apache SVN on CentOS

Checkout your repository

# svn co http://example.com/svn/myrepo01/

It will create a directory with repository name. Create some files and add them in repository.

# cd myrepo01/
# touch file1.txt file2.txt
# svn add file1.txt index.php

Commit new files to SVN repository.

# svn ci file1.txt index.php -m "initial commit"

trunk, branches and tags are common convention used by repositories. You can create that structure for your repository if require.

# mkdir -p myrepo01/{trunk,branches,tags}
# svn import -m 'Initializing structure' myrepo01/  http://localhost/svn/myrepo01/

If it works you can start using your repository from any client software like “tortoise SVN

FacebookTwitterGoogle+RSS