前几天搭好了SVN服务器。
现在有一个很不好的现象就是网上搜到的问题解决方式都是复制粘贴,大部分都是浪费时间,让人感到绝望。
今天中午有空,就总结一下如何搭建svn服务器。
————————————————分割线——————————————
首先测试一下系统是否安装了SVN
执行命令svnserve –version
如果没有安装就执行 yum -y install subversion
1、建立SVN的根目录
mkdir -p /home/svn/
2、建立一个产品仓库
mkdir -p /home/svn/shop/
svnadmin create /home/svn/shop/
3、修改版本配置库文件
vi /home/svn/shop/conf/svnserve.conf
修改成
- realm = shop (这里shop就是你版本库的名字)
- authz-db = authz
- password-db = passwd
- auth-access = write
- anon-access = none # 注意这里必须设置,否则所有用户不用密码就可以访问
4、开始设置passwd用户账号信息vi /home/svn/shop/conf/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.
- ### 在下面添加用户和密码,每行一组username = password
- [users]
- # harry = harryssecret
- # sally = sallyssecret
- ###===========下面是我添加的用户信息========#######
- user= password
5、开始设置authz. 用户访问权限vi /home/svn/shop/conf/authz
- ### This file is an example authorization file for svnserve.
- ### Its format is identical to that of mod_authz_svn authorization
- ### files.
- ### As shown below each section defines authorizations for the path and
- ### (optional) repository specified by the section name.
- ### The authorizations follow. An authorization line can refer to:
- ### – a single user,
- ### – a group of users defined in a special [groups] section,
- ### – an alias defined in a special [aliases] section,
- ### – all authenticated users, using the ‘$authenticated’ token,
- ### – only anonymous users, using the ‘$anonymous’ token,
- ### – anyone, using the ‘*’ wildcard.
- ###
- ### A match can be inverted by prefixing the rule with ‘~’. Rules can
- ### grant read (‘r’) access, read-write (‘rw’) access, or no access
- ### (”).
- [aliases]
- # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil,
- Ltd./OU=Research Institute/CN=Joe Average
- # [groups]
- # harry_and_sally = harry,sally
- # harry_sally_and_joe = harry,sally,&joe
- # [/foo/bar]
- # harry = rw
- # &joe = r
- # * =
- # [repository:/baz/fuz]
- # @harry_and_sally = rw
- # * = r
- ###——————–下面我新加的————————###
- ###屏蔽掉上面的[groups] 因为在下面添加了
- [groups]
- devteam = user1, user2#devteam 项目组包括两个用户user1,user2
- [shop:/]
- @devteam = rw 项目组的成员对shop都有读写权限。
6、启动svn:svnserve -d -r /home/svn/ #默认的启动端口号为3690-d表示以daemon方式(后台运行)运行;-r /home/svn 指定根目录是/home/svn。
7、检查是否启动netstat -tunlp | grep svn如果显示以下信息说明启动成功tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN 10973/svnserve
最后就可以 通过客户端(小乌龟)进行访问 svn://{your-server-ip}/shop/ 根据提示输入账号密码即可。
ps:
1.
一定要注意,所购买的服务器是或否开启了3690端口并且对外开放,可以在本地telnet ip 3690 ,如果提示无法连接,那么说明3690端口不对外开放,需要去阿里云安全组中修改安全规则。(当初就是这个问题卡了我几天,在服务器上修改iptables都没有用— —)
2.
如果连接svn服务器提示option except 说明,svnserve.conf 中配置语句前面有一个空格,应该删掉。
3.
最后代码迁出 注意开头是svn:ip