[groups] ##这个模块是定义对代码仓库操作权限的用户组,不同的用户具有不同的操作权限
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# [/foo/bar]
# harry = rw
# &joe = r
# * =
admins = liu,user1 ##定义admins这个用户组,组内有两个用户分为别liu,user1
[/] ##中括号里面“/”表示 /data/svnroot/myproject/目录
@admins =rw ##admins这个用户组对代码项目目录具有读写权限
* = r ##其他用户组只具备读权限
[myproject:/] ##这里用来定义/data/svnroot/目录下有多个项目代码的时候
user1 = rw
编辑 passwd ,定义用户名和密码
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
liu = liu_!(!@#
user1 = user1!@#
user2 = user2!@#
编辑svnserve.conf ,在[general]增加如下配置
[general]
anon-access = none ##匿名用户没有任何权限
auth-access = write ##被授权用户具有写权限
password-db = passwd ##授权用户的密码存放位置
authz-db = authz ##指定权限控制文件
realm = /data/svnroot/myproject ##定义对哪个项目目录生效
4.启动svn服务
[root@server-1 conf]# svnserve -d -r /data/svnroot/
[root@server-1 conf]# ps aux |grep svnserver
root 18670 0.0 0.0 112660 976 pts/0 S+ 14:54 0:00 grep --color=auto svnserver
[root@server-1 conf]# netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 18592/svnserve
五、如何配置SVN客户端(Linux)
1.安装SVN客户端软件
[root@client ~]# yum install -y subversion
2.SVN客户端检出操作和提交操作
[root@client ~]# mkdir svntest
[root@client ~]# cd svntest/
[root@client svntest]# svn checkout svn://10.71.11.1/myproject --username=user2 ##注意,这条命令实现从svn服务端10.71.11.1上检出项目程序代码,使用user2这个用户和密码
Authentication realm: <svn://10.71.11.1:3690> /data/svnroot/myproject
Password for 'user2':
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<svn://10.71.11.1:3690> /data/svnroot/myproject
can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/root/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
Checked out revision 0.
[root@client svntest]# ls ##成功将远端服务上的项目程序代码拉到本地,就可以修改代码
myproject
那么如何把本地修改的代码上床到SVN服务端呢?
常见错误01:
[root@client ~]# cd svntest/
[root@client svntest]# ls
myproject
[root@client svntest]# touch svntest01
[root@client svntest]# ls
myproject svntest01
[root@client svntest]# svn add svntest01
svn: E155007: '/root/svntest' is not a working copy
原因分析:因为从SVN服务端检出的目录是/myprojec,因此必须进入到这个目录下向SVN服务端提交本地修改的代码
常见错误02
[root@client svntest]# cd myproject/
[root@client myproject]# ls
[root@client myproject]# touch test01
[root@client myproject]# ls
test01
[root@client myproject]# svn add test01
A test01
[root@client myproject]# svn commit -m "add test01"
svn: E170001: Commit failed (details follow):
svn: E170001: Authorization failed
查看工作副本中的状态
[root@client myproject]# svn status
A fstab
A test01
此时fstab的状态为A,它意味着这个文件已经被成功地添加到了版本控制中。
为了把 fstab存储到版本库中,使用 commit -m 加上注释信息来提交。