Linux下安装配置SVN独立服务器svnserve

默北 SVN318,6055字数 4249阅读14分9秒阅读模式

svn服务器有两种运行方式:独立服务器svnserve和借助apache作为apache的一个模块,以webdav/deltav协议通讯。
svn存储版本数据有两种方式:BDB和FSFS。BDB方式在服务器中断时,可能锁住数据。FSFS方式更安全些,兼容性好。
一.安装subversion

# wget http://subversion.tigris.org/downloads/subversion-1.6.13.tar.gz
 # wget http://subversion.tigris.org/downloads/subversion-deps-1.6.13.tar.gz
 # tar -xzvf subversion-1.6.13.tar.gz -C ../software/
 # tar -xzvf subversion-deps-1.6.13.tar.gz -C ../software/
 # cd ../software/subversion-1.6.13/
 # ./configure --prefix=/usr/local/subversion-1.6.13
 # make clean
 # make
 # make install
 # ./svnserve --version
 svnserve, version 1.6.13 (r1002816)
 compiled Jun 1 2011, 10:19:12
 Copyright (C) 2000-2009 CollabNet.
 Subversion is open source software, see http://subversion.tigris.org/
 This product includes software developed by CollabNet (http://www.Collab.Net/).
 The following repository back-end (FS) modules are available:
 * fs_fs : Module for working with a plain file (FSFS) repository.
 Cyrus SASL authentication is available.

输出以上信息说明安装成功。
二.建立库文件
1.创建文件夹文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# mkdir -p /www/svn/repository

2.创建版本库并指定数据存储模式为FSFS文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# ./svnadmin create --fs-type fsfs /www/svn/repository/
 # ls /www/svn/repository/
 conf db format hooks locks README.txt

3.创建项目临时目录文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# mkdir -p /www/svn/tmp/{trunk,tags,branches}

4.复制项目文件到trunk目录下文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# cp -r nginx /www/svn/tmp/trunk/

5.导入所需管理的项目到版本库repository中文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# ./svn import /www/svn/tmp/ file:///www/svn/repository/ -m "first import"
 -m 标识操作的注释
 /ww/svn/tmp/trunk/nginx 项目文件的位置
 file:///www/svn/repository 创建的软件仓库
 Adding /www/svn/tmp/trunk/nginx/client_body_temp
 Adding /www/svn/tmp/trunk/nginx/uwsgi_temp
 Adding /www/svn/tmp/trunk/nginx/logs
 Adding /www/svn/tmp/trunk/nginx/logs/access.log
 Adding /www/svn/tmp/trunk/nginx/logs/error.log
 Adding /www/svn/tmp/trunk/nginx/html
 Adding /www/svn/tmp/trunk/nginx/html/50x.html
 Adding /www/svn/tmp/trunk/nginx/html/index.html
 Adding /www/svn/tmp/trunk/nginx/fastcgi_temp
 Adding /www/svn/tmp/trunk/nginx/conf
 Adding /www/svn/tmp/trunk/nginx/conf/uwsgi_params
 Adding /www/svn/tmp/trunk/nginx/conf/fastcgi_params
 Adding /www/svn/tmp/trunk/nginx/conf/uwsgi_params.default
 Adding /www/svn/tmp/trunk/nginx/conf/fastcgi.conf
 Adding /www/svn/tmp/trunk/nginx/conf/fastcgi_params.default
 Adding /www/svn/tmp/trunk/nginx/conf/fastcgi.conf.default
 Adding /www/svn/tmp/trunk/nginx/conf/nginx.conf
 Adding /www/svn/tmp/trunk/nginx/conf/scgi_params
 Adding /www/svn/tmp/trunk/nginx/conf/win-utf
 Adding /www/svn/tmp/trunk/nginx/conf/nginx.conf.default
 Adding /www/svn/tmp/trunk/nginx/conf/mime.types
 Adding /www/svn/tmp/trunk/nginx/conf/scgi_params.default
 Adding /www/svn/tmp/trunk/nginx/conf/mime.types.default
 Adding /www/svn/tmp/trunk/nginx/conf/koi-win
 Adding /www/svn/tmp/trunk/nginx/conf/koi-utf
 Adding /www/svn/tmp/trunk/nginx/proxy_temp
 Adding /www/svn/tmp/trunk/nginx/scgi_temp
 Adding /www/svn/tmp/trunk/nginx/sbin
 Adding (bin) /www/svn/tmp/trunk/nginx/sbin/nginx
 Committed revision 1.

6.检查是否导入成功文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# ./svn list --verbose file:///www/svn/repository/
 1 root Jun 01 10:48 ./
 1 root Jun 01 10:48 client_body_temp/
 1 root Jun 01 10:48 conf/
 1 root Jun 01 10:48 fastcgi_temp/
 1 root Jun 01 10:48 html/
 1 root Jun 01 10:48 logs/
 1 root Jun 01 10:48 proxy_temp/
 1 root Jun 01 10:48 sbin/
 1 root Jun 01 10:48 scgi_temp/
 1 root Jun 01 10:48 uwsgi_temp/

7.修改版本库文件的权限文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# chmod 770 repository
 # chmod -R g+w repository

三.用户管理
1.修改版本库的配置文件文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# vim /www/svn/repository/conf/svnserve.conf
 [general]
 anon-access = read
 auth-access = write
 password-db = passwd
 authz-db = authz
 realm = repository
 [sasl]

2.修改允许访问版本库的用户文件文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# vim /www/svn/repository/conf/passwd

文件格式如下所示:文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

[users] //不可省略
 username1=password1
 username2=password2 //每个用户一行

新建用户列表文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

xuhh = xuhh@ttlsa.com

3.修改用户访问版本库的权限文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# vim /www/svn/repository/conf/authz

注意:权限配置文件中出现的用户名必须在passwd文件中有定义过,对权限配置文件authz的修改会立即生效。
文件格式如下所示:
用户组格式:文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

[groups]
 user_group_name=username1,username2 //用户间以逗号分割

版本库目录格式:文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

[repository:/project/directory] //版本库:/项目/目录
 @user_group_name=permissions //用户组名=权限
 username=permissions //用户名=权限

[]可以有多种定义 /表示对全部的版本库设置权限,repos1:/表示对repos1设置权限,repos2:/www表示对repos2中的www项目设置权限,repos2:/www/example.com表示对repos2中的www项目的example.com目录设置权限。
可以用*来表示所有用户。
权限可以设置为w,r,wr和空,空表示没有任何权限。
新建用户访问版本库权限文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

[aliases]
 [groups]
 developer = xuhh
 [/]
 @developer = rw

四.启动和停止subversion
1.启动svn文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# ./svnserve -d --listen-port 9999 -r /www/svn/repository --log-file /usr/local/subversion-1.6.13/logs/svn.log --pid-file /usr/local/subversion-1.6.13/logs/svn.pid

-d 以daemon方式运行
--listen-port 监听端口号
-r 指定目录
--log-file 指定日志文件
--pid-file 指定pid文件
2.停止svn文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# kill -9 `cat /usr/local/subversion-1.6.13/logs/svn.pid`

五.客户端访问
1.Windows下安装TortoiseSVN
2.Linux下文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

# svn checkout svn://192.168.50.10:9999

转载请注明出处:https://www.ttlsa.com/html/711.html文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/

文章源自运维生存时间-https://www.ttlsa.com/svn/install-svnserve-on-linux/
weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
默北
  • 本文由 发表于 18/12/2011 15:33:16
  • 转载请务必保留本文链接:https://www.ttlsa.com/svn/install-svnserve-on-linux/
  • FSFS
  • Linux
  • subversion
  • svn
  • svnserve
  • 安装
  • 服务器
  • 独立
  • 配置
评论  3  访客  2
    • 有课
      有课 9

      4.复制项目文件到trunk目录下
      cp -r nginx /www/svn/tmp/trunk/
      这里不太明白,复制一个nginx是什么意思呢?就是测试的时候随便复制的一个文件吗?

    评论已关闭!