Linux 搭建SVN服务器(B/S模式)

提示:本教程SVN服务(B/S模式)采用架构 ( subversion + apache + submin )

Submin软件是第三方提供(已经停止更新),需要到官网下载 https://supermind.nl/ (官网需要翻墙才可以打开),官网下载不了可以到第三方网站下载RPM包安装即可 http://rpmfind.net/

Linux System Environment

[root@client01 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@client01 ~]# uname -r
3.10.0-862.el7.x86_64
[root@client01 ~]# uname -m
x86_64
[root@client01 ~]# echo $LANG
en_US.UTF-8

一、配置阿里云yum源和epel源
提示:阿里云yum源官网 https://developer.aliyun.com/mirror/

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache

二、关闭防火墙和SElinux
提示:BS模式的SVN使用默认端口 80

systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
cat /etc/selinux/config
setenforce 0
getenforce

三、yum安装SVN软件

rpm -qa subversion       ##查看是否已经安装SVN软件,如果已安装就不用再继续安装
yum -y install subversion
svn --version

四、yum安装并启动Apache
提示:httpd配置目录 /etc/httpd/ ,启动apache后需要使用浏览器打开测试一下

yum -y install httpd
systemctl enable httpd.service
systemctl start httpd.service
systemctl status httpd.service

五、安装Apache和python对SVN支持的模块

yum -y install mod_dav_svn
yum -y install subversion-python

六、下载submin并安装
提示:建议使用window下载submin源码rpm安装包上传到linux再进行安装

[root@client01 ~]# yum -y install vim lrzsz
[root@client01 ~]# rpm -ivh submin-2.2.1.1-lp152.3.3.src.rpm
[root@client01 SOURCES]# tar xf /root/rpmbuild/SOURCES/submin-2.2.1-1.tar.gz
[root@client01 SOURCES]# cd /root/rpmbuild/SOURCES/submin-2.2.1-1
[root@client01 submin-2.2.1-1]# python setup.py install
[root@client01 ~]# submin2-admin      ###显示submin版本说明安装成功
Submin 2.2.1
[root@client01 ~]# submin2-admin /opt/submin initenv [[email protected]](mailto:[email protected]) ###初始化submin配置需要等待1分钟就会显示配置,[[email protected]](mailto:[email protected])填写个人邮箱,/opt/submin 此SVN初始化目录不需要先创建
Submin can enable features for you automatically. Please answer which features
you want to enable. You can choose to enable: 'svn', 'git', 'trac', 'apache'
and 'nginx'.
Which features do you want to enable? [svn, git, apache, nginx]> svn,apache     #指定要开启哪些功能
Please provide a location for the Subversion repositories. For new Subversion
repositories, the default setting is ok. If the path is not absolute, it will
be relative to the submin environment. If you want to use an existing
repository, please provide the full pathname to the Subversion parent
directory (ie. /var/lib/svn).
Path to the repository? [svn]> /opt/svn     # #指定SVN版本库目录
Please provide a hostname that can be used to reach the web interface. This
hostname will be used in communication to the user (a link in email, links
in the web interface). The hostname should be a FQDN, so instead of 'foo' it
should be 'foo.example.com'. Please correct if the default is incorrect.
Hostname? [client01]> 192.168.201.56      ##指定主机IP
The HTTP path tells Submin where the website is located relative to the root.
This is needed for proper working of the website. Submin will be accesible
from /submin, Subversion will be accessible from /svn.
If you use Trac, it will be accessible from /trac.
HTTP base? [/]>                             ##按回车即可
Submin will send emails for password resets and for commit message (if
enabled). You can set the sender email address that Submin will use. The
default might work in some places, but not all.
Email from envelope? [Submin ]>    #按回车即可

#一定要注意SVN和GIT版本库目录要给apache用户写权限,否则会报错
[root@client01 ~]# chown apache:apache /opt/svn/

七、配置Apache软链接

ln -s /opt/submin/conf/apache-2.4-webui-cgi.conf /etc/httpd/conf.d/
ln -s /opt/submin/conf/apache-2.4-svn.conf /etc/httpd/conf.d/

八、重启Apache

yum -y install apr-util-sqlite apr-util     #需要yum安装sqlite3做数据库,否则会报错Can’t load driver file apr_dbd_sqlite3.so
systemctl restart httpd.service

九、诊断submin

submin2-admin /opt/submin/ diagnostics

十、重置submin管理员密码

cat /var/spool/mail/root #重启Apache服务会有一个邮件提示修改管理员密码
http://192.168.201.56/submin/password/admin/xfJlSA9GVTJUn5AkMlllJJPqPOXzCaBsaXYcxu7j7eRYuywz6i ##此链接地址都不一样,请使用个人安装submin生成的链接,修改admin管理员密码会提示错误,这个错误只需要开启git功能即可

image.png

image.png
submin2-admin /opt/submin git init     #执行这条命令直接按回车即可
image.png

特殊操作:(submin内置命令)

###submin命令用法
[root@test001 ~]# submin2-admin /opt/submin/ config 
Usage:
        config defaults                 - create config with defaults
        config get                      - list everything
        config get 

你可能感兴趣的:(Linux 搭建SVN服务器(B/S模式))