Setting Up SVN and Git Remote Repositories on CentOS 7.6 Server

Creating System User for Repository Management

Begin by creating a dedicated system account without a home directory:

useradd -M developer_user

The -M flag prevents automatic creation of the /home/developer_user directory.

Establish a password for the new user:

passwd developer_user

Follow the prompts to enter the desired password twice.

Establishing User Groups

Create an SVN-specific group:

groupadd repository_group

Assign the user to the newly created group:

usermod -G repository_group developer_user

Installing Subversion

Verify if SVN is already installed:

svnserve --version

If not present, install via yum:

yum -y install subversion

Creating SVN Repository Structure

Generate the repository directory structure:

mkdir -p /opt/repository_root/project_repo
svnadmin create /opt/repository_root/project_repo

Navigate to examine the generated configuration files:

cd /opt/repository_root/project_repo
ls -la

Expected directory structure:

drwxr-xr-x. 2 root root 54 Mar 2 22:49 conf
drwxr-sr-x. 6 root root 253 Mar 2 22:51 db
-r--r--r--. 1 root root 2 Mar 2 22:47 format
drwxr-xr-x. 2 root root 231 Mar 2 22:47 hooks
drwxr-xr-x. 2 root root 41 Mar 2 22:47 locks
-rw-r--r--. 1 root root 229 Mar 2 22:47 README.txt

To remove a repository:

rm -rf /opt/repository_root/project_repo

Copy essential configuration files to the parent directory:

cd /opt/repository_root/project_repo/conf
cp authz /opt/repository_root/
cp passwd /opt/repository_root/

Configure the main SVN server settings in svnserve.conf:

[general]
# Disable anonymous access
anonymous_access = none
# Grant write permissions to authenticated users
authenticated_access = write
# Reference shared password file
password_database = /opt/repository_root/passwd
# Reference shared authorization file
authorization_database = /opt/repository_root/authz
# Define authentication realm
realm = /opt/repository_root/project_repo/

Configuring User Authentication

Edit the password file:

vi /opt/repository_root/passwd

Sample configuration:

[users]
# Format: username = password
administrator = admin_password
test_user = test_password
john = john_password
mary = mary_password
david = david_password
sarah = sarah_password

Configure authorization rules in the authz file:

vi /opt/repository_root/authz

Authorization configuration example:

[aliases]

[groups]
administrators = administrator
testers = test_user
project_developers = john,mary
department_users = david,sarah

# Root directory permissions
[/]
@administrators = rw

# Project repository root
[project_repo:/]
@project_developers = rw

# Specific directory within project
[project_repo:/documents]
@testers = r

# Alternative repository
[alternative_repo:/]
@department_users = rw

# Specific path in alternative repo
[alternative_repo:/temp]
@testers = r

Creating Startup Script

Generate a startup script in the init directory:

cd /etc/init.d
touch svn_daemon
chmod u+x svn_daemon

Complete startup script:

#!/bin/bash
# chkconfig: 2345 15 85
# description: Subversion server daemon

REPO_ROOT=/opt/repository_root

if [ ! -f "/usr/bin/svnserve" ]
then
  echo "svnserve startup: cannot start"
  exit 1
fi

case "$1" in
  start)
    echo "Starting svnserve daemon..."
    /usr/bin/svnserve -d --listen-port 3690 -r $REPO_ROOT
    echo "Startup complete!"
    ;;
  stop)
    echo "Stopping svnserve daemon..."
    killall svnserve
    echo "Shutdown complete!"
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: svn_service { start | stop | restart }"
    exit 1
esac

Starting SVN Service

Launch the service:

service svn_daemon start

Verify the process is running:

ps -ef | grep 'svnserve'

Expected output shows the daemon listening on port 3690.

For system-level integration, configure the service to start automatically:

chkconfig --add svn_daemon
chkconfig svn_daemon on

Enable the firewall port for SVN access:

firewall-cmd --zone=public --add-port=3690/tcp --permanent
firewall-cmd --reload

HTTP-based Access Configuration

Install Apache web server:

yum install httpd

Verify installation:

httpd -version

Install SVN Apache modules:

yum install mod_dav_svn

Locate module files:

find / -name mod_dav_svn.so
find / -name mod_authz_svn.so

Adjust ownership of repository directory:

chown -R apache:apache /opt/repository_root

Create HTTP authentication file:

touch /opt/repository_root/http_auth
htpasswd -c /opt/repository_root/http_auth admin_user
htpasswd /opt/repository_root/http_auth guest_user

Configure Apache virtual host:

touch /etc/httpd/conf.d/svn_access.conf
echo '<Location /repositories>
    DAV svn
    SVNParentPath /opt/repository_root
    AuthType Basic
    AuthName "Repository Access"
    AuthUserFile /opt/repository_root/http_auth
    AuthzSVNAccessFile /opt/repository_root/authz
    Require valid-user
</Location>' > /etc/httpd/conf.d/svn_access.conf

Start Apache service:

service httpd start

Access repositories via http://your_server_ip/repositories/project_repo

Configure firewall for HTTP access:

firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload

Git Repository Setup

Git remote repository implemantation follows similar principles of user management, directory structure creation, and permisssion configuration. The primary differences lie in using Git-specific tools like git-daemon or SSH-based access methods instead of SVN protocols.

Tags: SVN Git centos repository server-setup

Posted on Sun, 19 Jul 2026 16:47:13 +0000 by Ofro04