How to Install an SVN Server on CentOS 6.3 64-bit

2012-08-13 00:00:00

This article describes in detail how to install an SVN server on CentOS 6.3 64-bit

Tools/Materials

Environment: linode vps centos6 64bit

SVN is a version control tool; installation is simple and convenient;

Standalone SVN server installation method

Setting up a standalone SVN server

Environment preparation

yum groupinstall "X Software Development" "Development Libraries" "Development Tools"

Download the required source packages

subversion-deps-1.6.17.tar.gz contains the support libraries and other files for SVN

How to Install an SVN Server on CentOS 6.3 64-bit

wget http://subversion.tigris.org/downloads/subversion-deps-1.6.17.tar.gz

subversion-1.6.17.tar.gz is the main SVN program

wget http://subversion.tigris.org/downloads/subversion-1.6.17.tar.gz

Compile and install from source

Both packages must be extracted into the same directory

tar zxvf subversion-deps-1.6.17.tar.gz

tar xvf subversion-1.6.17.tar.gz

cd subversion-1.6.17

./configure --prefix=/opt/svn

make && make install

Modify the environment variables

vi /etc/profile, and add the following at the end of /etc/profile:

PATH=$PATH:/opt/svn/bin

export PATH

Verify whether the installation succeeded

svnserve --version

If the following information is displayed, the installation succeeded.

svnserve, version 1.6.17 (r1128011)

compiled Mar 23 2012, 16:57:41

Configure SVN

The system adopts the strategy of creating a separate repository for each project. Configuration files, password files, access control files, etc. are all placed in

the conf directory of the repository. Therefore, every time you start a new project you must create a new repository and reconfigure each

configuration file. Another very important point: each team member must reconfigure the client, including the server repository path, local

path and other information.

Create the SVN repository testsvn

mkdir /var/svn

cd /var/svn

svnadmin create testsv

cd testsv

[root@nagios testsv]# ls

conf db format hooks locks README.txt

[root@nagios testsv]# cd conf/

[root@nagios conf]# ls

authz passwd svnserve.conf

Configure repository information

[root@nagios conf]# vi svnserve.conf

[general]

anon-access = none

auth-access = write

password-db = passwd

authzauthz-db = authz

realm = testsv (name of the repository)

[sasl]

# use-sasl = true

# min-encryption = 0

# max-encryption = 256

Define repository access permissions

[root@nagios conf]# vi authz

[aliases]

# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe

Average

[groups]

# harryharry_and_sally = harry,sally

# harryharry_sally_and_joe = harry,sally,&joe

# [/foo/bar]

# harry = rw

# &joe = r

# * =

# [repository:/baz/fuz]

# @harry_and_sally = rw

# * = r

# Add the following two lines

[/]

testuser = rw

[testsv]

testuser = rw

Define user passwords

[root@nagios conf]# cat passwd

[users]

# harry = harryssecret

# sally = sallyssecret

testuser = testsv123456

Start the SVN service

Create a user for starting SVN

useradd svn

passwd svn

Set a password for user svn as prompted

Allow user svn to access the repository

chown -R svn:svn /var/svn

Start SVN

(1) Start with the configured account

su svn -c "svnserve -d --listen-port 9999 -r /var/svn"

Where:

su svn means starting SVN as user svn

-d means running in daemon mode (in the background)

–listen-port 9999 means using port 9999, which can be replaced with the port you need. Note that using a port below 1024

requires root privileges

-r /var/svn specifies the root directory as /var/svn

(2) For a single code repository:

Start command:

svnserve -d -r folder path --listen-host 192.168.100.131

Where -d means running in the background and -r specifies the server root directory, so that the server can be accessed directly via svn://

the server IP.

If the server has multiple IPs, use –listen-host to specify the IP address to listen on.

We can access the SVN server from the SVN client via svn://192.168.100.131

(3) For multiple code repositories:

At startup we can also use the -r option to specify the server root directory, but when accessing, you need to write the path of each repository relative to the SVN

root directory.

For example, if we have two code repositories /var/svn/testsv

svnserve -d -r /var/svn --listen-host 192.168.1.100

to start,

then when accessing from the client you can use svn://192.168.100.100/testsv to access the two projects respectively. Once startup is

complete,

My startup method:

[root@austit fabian]# svnserve -d -r /var/svn --listen-host 192.168.100.131

Note:

The default SVN port is 3690, and you need to open this port on the firewall. You can also use the –listen-port

option of svnserve to specify another already-open port, but in that case the client must also append the port, e.g.

svn://192.168.100.200:8888/

Check whether startup succeeded

(check whether the svnserve process exists)

ps -ef|grep svnserve

If the following is displayed, startup succeeded:

svn 6941 1 0 15:07 ? 00:00:00 svnserve -d –listen-port 9999 -r /var/svn

I started it with the root account:

[root@austit fabian]# svnserve -d -r /var/svn --listen-host 192.168.100.131

[root@austit fabian]# ps -ef|grep svnserve

root 4513 1 0 21:07 ? 00:00:00 svnserve -d -r /var/svn --listen-host 192.168.100.131

root 4515 4409 0 21:07 pts/1 00:00:00 grep svnserve

Using SVN

Then users can simply download a client to access it; TortoiseSVN is recommended.

Notes

Try not to use the SVN version server bundled with CentOS

Do not disconnect the SSH session during installation, otherwise unknown errors can easily occur. You can use screen to avoid SSH disconnection problems.

« Back to News list