CentOS7搭建svn服务器

网站优化

  1,svn安装

  通过yum命令进行安装,命令如下:

  [root@localhost ~]$ yum -y install subversion

  已加载插件:fastestmirror, langpacks

  Loading mirror speeds from cached hostfile

  * base: mirrors.bfsu.edu.cn

  * extras: mirrors.dgut.edu.cn

  * updates: mirrors.aliyun.com

  base

   3.6 kB 00:00:00

  extras

   2.9 kB 00:00:00

  updates

   2.9 kB 00:00:00

  正在解决依赖关系

  --> 正在检查事务

  ---> 软件包 subversion.x86_64.0.1.7.14-16.el7 将被 安装

  --> 正在处理依赖关系 subversion-libs(x86-64) = 1.7.14-16.el7,它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_wc-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_subr-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_repos-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_ra_svn-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_ra_neon-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_ra_local-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_ra-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_fs_util-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_fs_fs-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_fs_base-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_fs-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_diff-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_delta-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libsvn_client-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 subversion-1.7.14-16.el7.x86_64 需要

  --> 正在检查事务

  ---> 软件包 apr.x86_64.0.1.4.8-7.el7 将被 安装

  ---> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装

  ---> 软件包 subversion-libs.x86_64.0.1.7.14-16.el7 将被 安装

  --> 解决依赖关系完成

  依赖关系解决

  =========================================================================================================================================================================

  Package 架构 版本 源 大小

  =========================================================================================================================================================================

  正在安装:

  subversion x86_64 1.7.14-16.el7 base 1.0 M

  为依赖而安装:

  apr x86_64 1.4.8-7.el7 base 104 k

  apr-util x86_64 1.5.2-6.el7 base 92 k

  subversion-libs x86_64 1.7.14-16.el7 base 922 k

  事务概要

  =========================================================================================================================================================================

  安装 1 软件包 (+3 依赖软件包)

  总下载量:2.1 M

  安装大小:7.5 M

  Downloading packages:

  (1/4): apr-util-1.5.2-6.el7.x86_64.rpm

   92 kB 00:00:02

  (2/4): apr-1.4.8-7.el7.x86_64.rpm

   104 kB 00:00:03

  (3/4): subversion-1.7.14-16.el7.x86_64.rpm

   1.0 MB 00:00:09

  (4/4): subversion-libs-1.7.14-16.el7.x86_64.rpm

   922 kB 00:00:22

  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  总计 96 kB/s

   2.1 MB 00:00:22

  Running transaction check

  Running transaction test

  Transaction test succeeded

  Running transaction

  正在安装 : apr-1.4.8-7.el7.x86_64 1/4

  正在安装 : apr-util-1.5.2-6.el7.x86_64 2/4

  正在安装 : subversion-libs-1.7.14-16.el7.x86_64 3/4

  正在安装 : subversion-1.7.14-16.el7.x86_64 4/4

  验证中 : subversion-libs-1.7.14-16.el7.x86_64 1/4

  验证中 : apr-1.4.8-7.el7.x86_64 2/4

  验证中 : subversion-1.7.14-16.el7.x86_64 3/4

  验证中 : apr-util-1.5.2-6.el7.x86_64 4/4

  已安装:

  subversion.x86_64 0:1.7.14-16.el7

  作为依赖被安装:

  apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.el7 subversion-libs.x86_64 0:1.7.14-16.el7

  完毕!

  2,创建svn版本库

  1)创建仓库文件夹,命令如下:

  [root@localhost opt]# mkdir -p /opt/svn/repository

  2)创建svn版本库,命令如下:

  [root@localhost opt]# svnadmin create /opt/svn/repository

  创建成功,进入/opt/svn/repository文件夹,信息如下:

  [root@localhost opt]# cd /opt/svn/repository/

  [root@localhost repository]# ll

  总用量 8

  drwxr-xr-x. 2 root root 54 6月 6 17:52 conf

  drwxr-sr-x. 6 root root 233 6月 6 17:52 db

  -r--r--r--. 1 root root 2 6月 6 17:52 format

  drwxr-xr-x. 2 root root 231 6月 6 17:52 hooks

  drwxr-xr-x. 2 root root 41 6月 6 17:52 locks

  -rw-r--r--. 1 root root 229 6月 6 17:52 README.txt

  3,权限配置

  进入/opt/svn/repository/conf目录,有如下三个文件:

  [root@localhost conf]# ll

  总用量 12

  -rw-r--r--. 1 root root 1080 6月 6 17:52 authz

  -rw-r--r--. 1 root root 309 6月 6 17:52 passwd

  -rw-r--r--. 1 root root 3090 6月 6 17:52 svnserve.conf

  文件说明:

  authz:负责账号权限的管理,控制账号是否读写权限

  passwd:负责账号和密码的用户名单管理

  svnserve.conf:svn服务器配置文件

  1)authz配置

  执行vim authz,配置关键信息如下:

  [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,&joeadmin=admindev=zhangsan,lisi,wangwu# [/foo/bar]# harry = rw# &joe = r# * =# [repository:/baz/fuz]# @harry_and_sally = rw# * = r#[/]表示根目录,即/opt/svn/repository/[/]#@加组名称,给该组赋权,r表示读,w表示写@admin=rw#[/dev]实际上为/opt/svn/repository/dev[/dev]@dev=rw

  2)配置passwd

  执行 vim passwd,配置svn访问用户和密码:

  ### 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# 等号前面为用户名,后面为登录密码admin = admin@123zhangsan = zhang@123lisi = li@123wangwu = wang@123

  3)配置 svnserve.conf

  执行vim svnserve.conf,配置访问权限,关键信息如下:

  ### users have read-only access to the repository, while authenticated### users have read and write access to the repository.anon-access = noneauth-access = write### users have read and write access to the repository.anon-access = noneauth-access = write### The password-db option controls the location of the password### database file. Unless you specify a path starting with a /,### the file's location is relative to the directory containing### this configuration file.### If SASL is enabled (see below), this file will NOT be used.### Uncomment the line below to use the default password file.password-db = passwd### The authz-db option controls the location of the authorization### rules for path-based access control. Unless you specify a path### starting with a /, the file's location is relative to the the### directory containing this file. If you don't specify an### authz-db, no path-based access control is done.### Uncomment the line below to use the default authorization file.authz-db = authz### This option specifies the authentication realm of the repository.### If two repositories have the same authentication realm, they should### have the same password database, and vice versa. The default realm### is repository's uuid.realm = /opt/svn/repository

  配置说明:

  anon-access = none:表示禁止匿名用户访问

  auth-access = write:表示授权用户拥有读写权限

  password-db = passswd:指定用户名口令文件,即passwd文件

  authz-db = authz:指定权限配置文件,即authz文件

  realm = /opt/svn/repository:指定认证域,即/opt/svn/repository目录

  4,启动svn服务

  svn默认端口为3690,可以指定端口启动,如3696,启动命令如下:

  [root@localhost ~]# svnserve -d -r /opt/svn --listen-port 3696

  启动成功后,通过ps -ef

   grep svn查看进程,显示如下信息:

  [root@localhost ~]# ps -ef

  grep svn

  root 12499 1 0 22:04 ? 00:00:00 svnserve -d -r /opt/svn --listen-port 3696

  root 13482 1386 0 22:05 pts/1 00:00:00 grep --color=auto svn

  5,客户端访问svn服务器

  使用IntelliJ IDEA编辑器,通过check out 拉取文件,如图:

  提交文件至svn服务器,如图:

  在此,svn服务器搭建完成,如果有问题,欢迎各位指正。

  注意事项:1,上述操作都是采用root权限进行

  2,需要关闭防火墙或者在防火墙配置中开放svn端口

标签: 网站优化