04_安装SVN

第四章 安装SVN

作者:张子默

一、安装前准备

安装文件及其依赖文件下载

  • apr-1.7.0.tar.gz: http://apr.apache.org/download.cgi
  • apr-util-1.6.1.tar.gz: http://apr.apache.org/download.cgi
  • sqlite-autoconf-3340000.tar.gz:https://www.sqlite.org/download.html
  • zlib-1.2.11.tar.xz: https://linux.softpedia.com/get/Programming/Libraries/zlib-159.shtml
  • subversion-1.14.0.tar.gz: http://subversion.apache.org/download/

二、安装SVN

1、创建用户、上传及解压文件

  • 执行命令useradd svn创建svn用户。
    在这里插入图片描述
  • 将下载文件利用U盘、磁盘或网络 上传到 /home/svn 目录下,我这里使用的是Xftp工具,选中文件,右键->传输。
    在这里插入图片描述
  • 对下载的软件包和依赖包进行解压。
tar -xzvf apr-1.7.0.tar.gz
tar -xzvf apr-util-1.6.1.tar.gz
tar -xzvf subversion-1.14.0.tar.gz
tar -xzvf sqlite-autoconf-3340000.tar.gz
#由于zlib是.tar.xz压缩文件,故需要两步,若为.tar.gz,同上
xz -d zlib-1.2.11.tar.xz
tar -xvf zlib-1.2.11.tar

2、安装软件

  • 安装aprapr-util
cd apr-1.7.0
./configure --prefix=/home/svn/apr-1.7.0
make
make test
make install

cd ..
cd apr-util-1.6.1
./configure --prefix=/home/svn/apr-util-1.6.1 --with-apr=/home/svn/apr-1.7.0
make
#若报错xml/apr_xml.c:35:10: 致命错误:expat.h:没有那个文件或目录,需要安装expat-devel,可在线安装,也可离线安装
yum install expat-devel
make test
make install
  • 安装zlib
cd ..
cd zlib-1.2.11
./configure --prefix=/home/svn/zlib-1.2.11
make
make install
  • 安装subversion
#安装之前需要将 sqlite包 移到 subversion 目录
cd ..
mv sqlite-autoconf-3340000 ./subversion-1.14.0/sqlite-amalgamation
#此处也许会报错,无法生成 Makefile 文件,解决方法如下
#报错:configure: error: Subversion requires LZ4 >= r129, or use --with-lz4=internal
#解决: ./configure命令添加 --with-lz4=internal
#报错:configure: error: Subversion requires UTF8PROC
#解决:./configure命令添加 --with-utf8proc=internal
#完整命令如下:

./configure --prefix=/home/svn/subversion-1.14.0 --with-apr=/home/svn/apr-1.7.0 --with-apr-util=/home/svn/apr-util-1.6.1 --with-zlib=/home/svn/zlib-1.2.11 --with-lz4=internal --with-utf8proc=internal
make
make install

3、配置环境变量

  • 执行命令vi /etc/profile添加环境变量。
    在这里插入图片描述

  • 执行命令source /etc/profile生效环境变量。
    在这里插入图片描述

  • 执行命令svnserve --version验证安装是否成功。
    在这里插入图片描述

三、搭建SVN仓库

1、创建SVN仓库

#在/home/svn目录下建立learn_catalog目录,用作仓库
mkdir -p /home/svn/learn_catalog
#以该文件夹创建仓库
svnadmin create /home/svn/learn_catalog
#如果创建成功,learn_catalog文件夹下会出现README.txt conf等文件
#在conf文件夹里还有authz、passwd、svnserve.conf三个文件

2、修改配置文件

  • 编辑账号密码文件,即passwd文件。
#在[user]下添加用户名及密码
### 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

#用户zhangrj
zhangrj=Sccba2018&

在这里插入图片描述

  • 编辑权限控制文件,及authz文件。
#在文件最后添加用户权限
#设置[/]代表根目录下所有的资源
[/]
zhangrj=rw

在这里插入图片描述

  • 编辑SVN服务配置文件,即svnserve.conf文件。
#对以下项取消注释,语句必须顶格(左边不能留空格),否则会出错
[general]
### The anon-access and auth-access options control access to the
#…
### users have read and write access to the repository.
#匿名访问的权限,可以是read,write,none,默认为read
anon-access = read
#使授权用户有写权限
auth-access = write
### The password-db option controls the location of the password
#…
### Uncomment the line below to use the default password file.
#指向验证用户名密码的数据文件 passwd
password-db = passwd
### The authz-db option controls the location of the authorization
#…
### Uncomment the line below to use the default authorization file.
#指向验证用户的权限配置文件 authz
authz-db = authz
### This option specifies the authentication realm of the repository.
#…
### is repository’s uuid.
#认证命名空间,填你的仓库地址,subversion会在认证提示里显示,并且作为凭证缓存的关键字
realm = /home/svn/learn_catalog

3、配置防火墙

#SVN默认使用的是3690端口
#永久打开3690端口(重启有效)
firewall-cmd --permanent --zone=public --add-port=3690/tcp
#重新加载防火墙,更新防火墙规则
firewall-cmd --reload
#查询3690端口是否已经打开
firewall-cmd --query-port=3690/tcp

4、启动SVN服务

svnserve -d -r /home/svn/learn_catalog
#/home/svn/learn_catalog 是你的SVN仓库

5、访问SVN仓库

  • 访问地址:svn://ip[:port]/。
  • 验证信息填设置的用户名和密码。

四、其他相关

1、SVN服务的启停

#查看SVN进程
ps -ef|grep svn|grep -v grep
root     29597     1  0 21:55 ?        00:00:00 svnserve -d -r /home/svn/learn_catalog
#检测SVN端口
netstat -ln |grep 3690
tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN
#关闭SVN
kill 29597

2、建立多个仓库

  • 把多个仓库放在同一个文件夹。
#建立三个文件夹,放在同一个父文件夹下(删掉原有仓库,或置于该文件夹下)
mkdir -p /svn/test1
mkdir -p /svn/test2
mkdir -p /svn/test3
#分别建立三个仓库
svnadmin create /svn/test1
svnadmin create /svn/test2
svnadmin create /svn/test3
  • 分别配置三个仓库,即分别修改conf下的authz、passwd、svnserve.conf,当然,你也可以先配置好一个,然后把conf文件夹分别复制到其他仓库。
  • (先关掉再打开)重启SVN服务。
#注意!启动的是所有仓库的父文件夹路径 /svn
svnserve -d -r /svn
  • TortoiseSVN连接:连接时由于主机上有多个数据仓库,所以在地址后要加上仓库名。
#具体到本例
#连接到test1仓库
svn://ip[:port]/test1 #不再是svn://ip[:port]/
#连接到test2仓库
svn://ip[:port]/test2
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值