1. Install the SVN server
Just install subversion directly with apt-get or yum (of course, you can also go to the official download and install it yourself)
sudo apt-get install subversion
2. Create a repository
svnadmin create /home/myrepos //The file directory here is set by yourself
Catalog usage description:
- hooks directory: the directory where hook script files are placed
- locks directory: The directory used to place subversion's db lock files and db_logs lock files, used to track clients accessing the file repository
- format file: It is a text file with only one integer in it, indicating the version number of the current file library configuration
- conf directory: is the configuration file of this warehouse (user access account, permissions, etc. of the warehouse)
3. Configure svnserve
After the above repository /home/myrepos is established, a conf folder will be generated under the folder, and there will be the following three files under /home/myrepos/conf
authz passwd svnserve.conf
We modify in turn
3.1, svnserve.conf modify the following parts:
anon-access = none //Prohibit anonymous access auth-access = write password-db = /home/svn/passwd //Use the password file uniformly authz-db = /home/svn/authz realm = project1 //authorized domain name, very important, write your project name
3.2, passwd is modified to:
Add two access users and passwords
[users] username = password //The username and password here are set by themselves test2 = 123456
Note: Modifications to the user configuration file take effect immediately without restarting the svn service.
3.3, add the following two lines at the end of authz (these two lines solve the problem of SVN client solving authorization failed)
Configure the authorization file for the new user
# vi /svn/project/conf/authz [groups] admin = xiaoran.shen,test1 user = test2 [/] @admin = rw @user = r * =
Format description:
Repository directory format:
[<Repository>:/Project/Directory]
@<user group name> = <permission>
<username> = <permissions>
/ means to set permissions on all subdirectories under the root directory (ie /svn/project directory);
[/abc] Indicates setting permissions on abc items in the database;
Create an admin group, group members include xiaoran.shen and test1
Create a user group with only test2 members;
The admin group has read and write permissions to the directory;
A single user test2 has read and write permissions;
*= indicates that all users except the permission user group set above have empty permissions. Empty permissions indicate that access to this directory is prohibited, which is very important and must be added.
Note: Modifications to the rights configuration file take effect immediately without restarting svn.
4. Start svnserve:
svnserve -d -r /home/myrepos/
Note: Do not use the system-provided /etc/init.d/svnserve start to start, because the system default startup script does not use the –r /svn/project parameter to specify a resource. In this case, when the svn service is started, the client connection will prompt an error like " svn: No repository found in 'svn://192.168.11.229/project' ".
默认svn服务器端口是3690。
杀死svn服务:
# ps -ef|grep svn
root 4642 1 0 16:08 ? 00:00:00 svnserve -d -r /svn/project/
root 4692 3676 0 16:13 pts/2 00:00:00 grep svn
# kill -9 4642
若要使用/etc/init.d/svnserve 脚本,可以修改start()函数部分,如下:
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
daemon --pidfile=${pidfile} $exec $args -r /svn/project
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
完成