Centos7 下的SVN安装与配置
1.关闭防火墙
临时关闭防火墙
systemctl stop firewalld
永久防火墙开机自关闭
systemctl disable firewalld
临时打开防火墙
systemctl start firewalld
防火墙开机启动
systemctl enable firewalld
查看防火墙状态
systemctl status firewalld
2.关闭SELinux
临时关闭SELinux setenforce 0 临时打开SELinux setenforce 1 查看SELinux状态 getenforce 开机关闭SELinux 编辑/etc/selinux/config文件,如下图,将SELINUX的值设置为disabled。下次开机SELinux就不会启动了。
3.安装svn
yum install subversion
查看版本
[root@heyong ~]# svn --version svnserve, version 1.7.14 (r1542130) compiled Apr 11 2018, 02:40:28 Copyright (C) 2013 The Apache Software Foundation. This software consists of contributions made by many people; see the NOTICE file for more information. Subversion is open source software, see http://subversion.apache.org/ The following repository back-end (FS) modules are available: * fs_base : Module for working with a Berkeley DB repository. * fs_fs : Module for working with a plain file (FSFS) repository. Cyrus SASL authentication is available.
4.创建SVN版本库
在/home下建立一个名为svn的仓库(repository),以后所有代码都放在这个下面,创建成功后在svn下面会多出几个文件夹。
[root@heyong ~]# mkdir -p /home/svn [root@heyong ~]# svnadmin create /home/svn [root@heyong ~]# ls /home/svn conf db format hooks locks README.txt [root@heyong ~]# cd /home/svn/conf/ [root@heyong conf]# ll total 12 -rw-r--r-- 1 root root 1080 Oct 29 16:43 authz -rw-r--r-- 1 root root 309 Oct 29 16:43 passwd -rw-r--r-- 1 root root 3090 Oct 29 16:43 svnserve.conf 其中: authz 是权限控制文件 passwd 是帐号密码文件 svnserve.conf 是SVN服务配置文件
5.配置passwd(创建用户)
[root@heyong conf]# vim passwd [users] test1=123456 test2=123456
6.配置authz
[root@heyong conf]# vi authz [/] admin=rw #对/home/svn/下所有文件具有可读可写权限; test1=r #只有只读权限; test2=r #只有只读权限 *= #其它用户均无任何权限
7.使用用户分组
[root@heyong conf]# vi authz [groups] group1 = admin group2 = test1,test2 [/] @group1 = rw #对/home/svn/下所有文件具有可读可写权限; @group2 = r #只有只读权限; * = #其它用户无任何权限
8.配置svnserve.conf
[root@heyong conf]# vim svnserve.conf 打开下面的5个注释 anon-access = read #匿名用户可读 auth-access = write #授权用户可写 password-db = passwd #使用哪个文件作为账号文件 authz-db = authz #使用哪个文件作为权限文件 realm = /home/svn # 认证空间名,版本库所在目录
注意:
最后一行的realm记得改成你的svn目录
打开注释时切记前面不要留有空格,否则可能有问题
9.启动与停止
[root@heyong conf]# svnserve -d -r /home/svn(启动)
[root@heyong conf]#killall svnserve(停止)
注意:
上述启动命令中,-d表示守护进程, -r 表示在后台执行。停止还可以采用杀死进程的方式
10.客户端连接
TortoiseSVN中使用地址svn://你的IP ,输入用户名和密码就能连接成功。 默认端口3690,如果你修改了端口,那么要记得加上端口号。
修改默认端口
第一种方法:
svnserve -d -r /mnt/svn --listen-port 端口号
第二种方法:
svnserve -d -r /mnt/svn --listen-host IP+端口号
11.启动时遇到的问题
1.启动svnserve时出现cannot bind server socket:address already in use
解决方法:
方法一:找出svnserve id 杀死掉进程 netstat -ntlp kill -9 id 方法二:重新指定一个端口号(默认端口3690) svnserve -d --listen-port 端口号 -r /opt/svndata/repos
2.启动svnserve时出现svnserve.conf:12: Option expected的问题解决方法
svnserve.conf:12: Option expected
解决方法:
因为subversion读取配置文件svnserve.conf时,无法识别有前置空格的配置文件,删除前置空格即可;
如:anon-access = read
3.检查是否启动成功:(查看是否存在svnserve 进程)
[root@heyong svn]# ps -ef|grep svnserve root 84455 1 0 17:28 ? 00:00:00 svnserve -d -r /home/svn root 103442 70110 0 18:35 pts/0 00:00:00 grep --color=auto svnserve
12.svn常见路径说明
1.查询安装的包
[root@heyong svn]# rpm -qa|grep subversion subversion-libs-1.7.14-14.el7.x86_64 subversion-1.7.14-14.el7.x86_64
2.svn几个常用目录
/etc 一些设置文件放置的目录 /usr/bin 一些可执行文件 /usr/lib64 一些程序使用的动态函数库 /usr/share/doc 一些基本的软件使用手册与帮助文档 /usr/share/man 一些man page文件
3.列出某些包的具体文件
[root@heyong svn]# rpm -ql subversion-1.7.14-14.el7.x86_64 /etc/subversion /etc/sysconfig/svnserve /run/svnserve /usr/bin/svn /usr/bin/svnadmin /usr/bin/svndumpfilter /usr/bin/svnlook /usr/bin/svnrdump /usr/bin/svnserve /usr/bin/svnsync /usr/bin/svnversion /usr/lib/systemd/system/svnserve.service