Configuring SVN under Linux

【转】http://www.cnblogs.com/wuhou/archive/2008/09/30/1302471.html

1. Install SVN

       under Ubuntu

  apt-get install subversion

       under Centos

        yum install subversion

2. Create svn repository

  1). Create svn directory: mkdir /home/.svn (use hidden directory)

  2). cd /home/.svn

  3). mkdir lining

  4). Create warehouse astar: svnadmin create /home/.svn/astar, after execution, the astar directory has directories and files created by svnadmin

  5). mkdir test

  6). Create warehouse test: svnadmin create /home/.svn/test, after execution, the test directory has directories and files created by svnadmin

3. Configure and manage svn

  1). The configuration file of each warehouse is under $repos/conf/, vi svnserve.conf, and the configuration items are under [general]:

    anon-access: The permissions of anonymous users, which can be read, write and none, the default value is read. Do not allow anonymous user access: anon-access=none

    auth-access: The authority to authenticate the user, which can be read, write, or none. The default value is write.

    password-db: The path to the password database, remove the # in front

    authz-db: The path of the authentication rule base, remove the # in front.

    Note: The lines of these configuration items must be in the top box, otherwise an error will be reported. After modifying the configuration, you need to restart svn to take effect.

  2). Configure the passwd file

    This is the password file of each user, which is relatively simple, that is, "username=password", which is in clear code. Such as allen=111111

  3). Configure the authz file

    1. [groups] section:为了便于管理,可以将一些用户放到一个组里边,比如:owner=allen,ellen

    2. groups下边的sections表示对一个目录的认证规则,比如对根目录的认证规则的section为[/]。设置单用户的认证规则时一个用户一行,如:

      [/]

      allen=rw  #allen对根目录的权限为rw

      ellen=r    #ellen对根目录的权限为r

      如果使用group,需要在group名字前加@,如

      @owner=rw  #group owner中的用户均为rw,等价于上边的两句话

    启动时如果从/home/.svn/astar启动,/就是astar目录,用如上方式以astar目录为根设置权限。

    如果从/home/.svn/启动,每个仓库根还是自己的起始目录。可以采用如上方式设置astar的权限,也可以采用如下方式:

      [astar:/] #对应aster库的权限

      @owner=rw

                       

                          [astar:/proj1] #对应aster库中proj1的权限

      @owner=rw

                          [astar:/proj2] #对应aster库中proj2的权限

      @owner=rw

 

    设置test的权限如下:

      [test:/]

      @harry_and_sally = rw

    简言之,每个仓库的根目录(/)就是自己的起始目录;[repos:/]这种方式只适用于多仓库的情况;[/]适合于单仓库和单仓库的方式。

    3. 不能跨越仓库设置权限。

4. 启动和停止svn

  1). 启动:

    1. 从astar目录启动,svnserve -d -r /home/.svn/astar,根目录(/)是astar,authz中规则的配置使用section[/]。访问方式为:

      svn://192.168.0.87/

    2. 从.svn目录启动,svnserve -d -r /home/.svn,根目录(/)是.svn,authz中对astar的配置使用section[astar:/] ,对test的配置使用section[test:/]。访问方式为:

      svn://192.18.0.87/astar

                          svn://192.18.0.87/test

    如果需要svn自启动,把命令加入/etc/rc.local中

  2). 检查svn服务器是否已经启动(svn默认使用3690端口):netstat -an | grep 3690

  3). 停止:killall svnserve

5. svn client

  推荐使用TortoiseSVN, http://tortoisesvn.tigris.org/

  Eclipse插件,http://subclipse.tigris.org/

6. 有用的url:

  http://hi.baidu.com/diyit/blog/item/46ea1b4c7ecfa3ffd72afcbd.html

  http://www.javaeye.com/topic/72489  

  http://www.javaeye.com/wiki/topic/162649

 

 

补充第1步的

 判断是否安装成功
#subversion -v

  svnserve, version 1.6.11 (r934486)
出现上面的提示,说明安装成功。

   如果提示如下:-bash: subversion: command not found
   经过查找发现:
  [root@]# svnserve --version

 

补充:如果客户端提交时候出:

 

Cant open file /home/.svn/astar/db/txn-current-lock: Permission denied

解决方案:sudo chmod 777 -R db/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326483566&siteId=291194637