Subversion (hereinafter referred to as svn) is a version management tool that has emerged in recent years and is the successor of cvs.
The svn server has 2 modes of operation:
1. Dedicated server
2. With apache.
The two methods have their own advantages and disadvantages, and you can configure them according to your own needs. I don’t need Http to access, only the client can Commit & update
That’s fine, so I chose the first way – a standalone SVN server.
There are also two ways for svn to store version data:
1. BDB
2. FSFS.
Because the BDB method may lock the data when the server is interrupted (my friend suffered from it when he was engaged in ldap, and there is no cure), so the FSFS method is safer, and I also choose this method.
My environment:
1. Svn server installation operating system: Centos 5.3, installation steps:
Get the svn installation package:
# wget
“http://subversion.tigris.org/downloads/subversion-1.6.6.tar.gz”
# wget
“http://subversion.tigris.org/downloads/subversion-deps-1.6.6.tar.gz”
Compile svn and log in as root user:
# tar xfvz subversion-1.6.6.tar.gz
# tar xfvz subversion-deps-1.6.6.tar.gz
# cd subversion-1.6.6
# ./configure –prefix=/opt/svn –without-berkeley-db
(Note: Run in svnserve mode, without apache compilation parameters. Store the repository in fsfs format, without compiling berkeley-db)
# make && make install
Add SVN Path at the end of /etc/profile for easy operation:
# vi /etc/profile
PATH=$PATH:/opt/svn/bin
export PATH
Test whether the installation is successful:
# svnserve –version
or
# /opt/svn/bin/svnserve –version
[root@hexu softs]# svnserve –version
If the following is displayed, svn installation is successful:
svnserve, version 1.6.6 (r40053)
compiled Dec 2 2009, 22:37:15
Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see
http://subversion.tigris.org/
This product includes software developed by CollabNet
(http://www.Collab.Net/).
The following repository back-end (FS) modules are
available:
* fs_fs : Module for working with a plain file (FSFS)
repository.
Cyrus SASL authentication is available.
2. svn configuration to create svn repository directory can create multiple:
Create a new folder:
# mkdir -p /opt/svndata/repos
Create svn repository:
# svnadmin create /opt/svndata/repos
Modify the svn repository configuration file repository:
# vi /opt/svndata/repos/conf/svnserve.conf
The content is modified to:
[general]
anon-access = none
auth-access = write
password-db = /opt/svn/conf/passwd.conf
authz-db = /opt/svn/conf/authz.conf
realm = repos
Note: Modifications to user configuration files take effect immediately without restarting svn.
passwk.conf [users] is required, the file format is as follows:
[users]
= = The users who want to access svn are listed below, one line for each user, example:
[users]
username = password
Configure svn user access rights:
# vi /opt/svn/conf/authz.conf
Note:
* Usernames appearing in the rights profile must have been defined in the user profile.
* Modifications to the permission configuration file take effect immediately without restarting svn.
User group format:
[groups]
= ,
Among them, a user group can contain one or more users, and the users are separated by commas.
Repository directory format:
[:/project/directory]
@ =
=
Among them, the part inside the box number can be written in various ways:
[/], means the root directory and below, the root directory is specified when svnserve starts, we specify it as /opt/svndata, [/] means set permissions for all version libraries.
[repos:/] means to set permissions on the repository repos
[repos2:/abc] means to set permissions for the abc project in the repository repos2
[repos2:/abc/aaa] means to set permissions on the aaa directory of the abc project in the repository repos2
The authority subject can be user group, user or *, user group is preceded by @, and * means all users.
Permissions can be w, r, wr and empty, and empty means no permission.
Example:
[groups]
admin = alan
[/]
@admin = rw
[repos1:/abc/aaa]
king = rw
[repos2:/pass]
king =
svn configuration is complete.
3. Start svn and create a user to start svn
# useradd svn
# passwd svn
Set a password for user svn according to the prompt
Allow user svn to access the repository:
# chown -R svn:svn /opt/svndata
start svn
# su – svn -c “svnserve -d –listen-port 9999 -r /opt/svndata”
Where:
su – svn means start svn as user svn
-d means to run in daemon mode (running in the background)
–listen-port 9999 means to use port 9999, which can be replaced with the port you need. But note that using ports below 1024 requires root privileges
-r /opt/svndata specifies that the root directory is /opt/svndata
Check:
ps -ef|grep svnserve
If it is displayed as follows, the startup is successful:
svn 6941 1 0 15:07 ? 00:00:00 svnserve -d –listen-port
9999 -r /opt/svndata
There are many ways to access svn through the web, please refer to the method of configuring websvn or configuring bsSvnBrowser.
Well, all configurations are complete, and you can use the client SVN to operate.
Server test:
# cd /tmp
# mkdir test
# touch test.txt
# svn import /tmp/test/ file:///opt/svndata/repos -m “this is thie
first import”
# mkdir -p /tmp/test2
# cd /tmp/test2
# svn co file:///opt/svndata/repos /tmp/test2/
or:
# svn co svn://{your-server-ip}:9999/repos/
You should now see the file test.txt.
Additional testing methods:
# telnet {your-server-ip} 9999 Check if the port is connected
If the above check fails, it may be that iptables is not enabled, just set iptables:
# vi /etc/sysconfig/iptables
Add to:
-A RH-Firewall-1-INPUT -p tcp –dport 9999 -j ACCEPT