Centos搭建SVN服务器记录

#安装svn的软件
[root@iZuf6bpoj0ndooseylgjjdZ local]# yum -y install subversion

#创建一个svn根目录
[root@iZuf6bpoj0ndooseylgjjdZ local]# mkdir svnRoot
[root@iZuf6bpoj0ndooseylgjjdZ local]# ls
aegis  bin  etc  games  include  java  lib  lib64  libexec  sbin  share  src  svnRoot


[root@iZuf6bpoj0ndooseylgjjdZ svnRoot]# mkdir code
[root@iZuf6bpoj0ndooseylgjjdZ svnRoot]# ls
code
#创建一个代码仓库 ,在当前的code目录下创建一个仓库
[root@iZuf6bpoj0ndooseylgjjdZ svnRoot]# svnadmin create ./code
[root@iZuf6bpoj0ndooseylgjjdZ svnRoot]# ls
code
[root@iZuf6bpoj0ndooseylgjjdZ svnRoot]# cd code
[root@iZuf6bpoj0ndooseylgjjdZ code]# ls
conf  db  format  hooks  locks  README.txt
[root@iZuf6bpoj0ndooseylgjjdZ code]# cd conf
[root@iZuf6bpoj0ndooseylgjjdZ conf]# ls
authz  passwd  svnserve.conf

#编辑svnserve.conf文件 修改svn服务配置
[root@iZuf6bpoj0ndooseylgjjdZ conf]# vi svnserve.conf 

------------------------------------
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
#指定需要认证的仓库名称 其中code就是上面安装仓库名称
realm = code

------------------------------------
[root@iZuf6bpoj0ndooseylgjjdZ conf]# ls
authz  passwd  svnserve.conf

#编辑passwd文件,添加可以访问的仓库的 用户名/密码
[root@iZuf6bpoj0ndooseylgjjdZ conf]# vi passwd 
------------------------------------
[users]
# harry = harryssecret
# sally = sallyssecret

#添加用户名和密码
liuyl = liuyl
------------------------------------             

[root@iZuf6bpoj0ndooseylgjjdZ conf]# ls
authz  passwd  svnserve.conf

#编辑authz文件,指定访问用户的具体操作权限
[root@iZuf6bpoj0ndooseylgjjdZ conf]# vi authz 

------------------------------
#指定code代码仓库的根目录访问权限
[code:/]
liuyl = rw
------------------------------------


[root@iZuf6bpoj0ndooseylgjjdZ conf]# ls
authz  passwd  svnserve.conf

#启动服务时一定要指定仓库的上级目录:如仓库的名称为code,它的上级目录就是svnRoot
[root@iZuf6bpoj0ndooseylgjjdZ conf]# svnserve -d -r /usr/local/svnRoot/

#查看是否启动成功,netstat 查看端口号和进程号。
[root@iZuf6bpoj0ndooseylgjjdZ conf]# netstat -tunlp | grep svn
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      1837/svnserve 

#本地环境测试链接      
[root@iZuf6bpoj0ndooseylgjjdZ conf]# svn checkout svn://localhost/code
Authentication realm: <svn://localhost:3690> code
Password for 'root': 
Authentication realm: <svn://localhost:3690> code
Username: liuyl
Password for 'liuyl': 

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://localhost:3690> code

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)? no
Checked out revision 0.

     备注:

1、默认情况下,再建立仓库时,默认是不会建立分支的,只能通过svn copy命令方式或者 用客户端,
  创建分支,创建分支后合并代码时,如果出现如下Unreadable path encountered; access denied 异常。
  需要将上面的svnserve.conf 中的anon-access = read 修改成 anon-access = none
    
2、 错误Not authorized to open root of edit operation,也是由于打开了匿名获取权限造成的,
     anon-access = none就可以了。
 
3、 上面svnRoot相当于windows 下面的 repository,可以在下面建立多个svn仓库,
    通过svnserve -d -r /usr/local/svnRoot/ 启动服务后,
    下面的仓库会根据自己下面的conf文件中配置加载相应的访问权限。

4、将svn服务注册到开机启动。编辑 rc.local文件 vi /etc/rc.d/rc.local
   添加如下内容:
   /usr/bin/svnserve  -d -r /usr/local/svnRoot/

    

 

 

猜你喜欢

转载自liuyunlong1229.iteye.com/blog/2389302