Centos7下 搭建SVN +Apache+iF.SVNAdmin支持https实现web管理SVN

转自 http://www.cnblogs.com/Sungeek/p/6905102.html ,在原文基础上,增加了一些问题的解决

软件包安装

1.安装apache
[root@iZbp1hvbibqwiui44dxo6bZ /]# yum install httpd -y

-y的含义, --assumeyes answer yes for all questions 可以通过 yum help查询

2.安装svn服务器(其中,mod_dav_svn是apache服务器访问svn的一个模块)
[root@iZbp1hvbibqwiui44dxo6bZ /]# yum install mod_dav_svn subversion -y
3.查询安装是否成功

查询apache版本

[root@iZbp1hvbibqwiui44dxo6bZ /]# httpd -version
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov  5 2018 01:47:09

查询svn版本

[root@iZbp1hvbibqwiui44dxo6bZ /]# svnserve --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.

[root@iZbp1hvbibqwiui44dxo6bZ /]# ls /etc/httpd/modules/ | grep svn
mod_authz_svn.so
mod_dav_svn.so

配置

在apache下配置svn

编辑subversion.conf文件

[root@iZbp1hvbibqwiui44dxo6bZ /]# vim /etc/httpd/conf.d/subversion.conf

添加如下内容(去掉注释内容,否则启动apche报错)

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
<Location /svn>
DAV svn
SVNParentPath /var/www/svn   #svn的根目录SSLRequireSSL
AuthType Basic               #Basic认证方式
AuthName "Authorization SVN"   #认证时显示的信息
AuthUserFile /var/www/svn/passwd      #用户文件&密码
AuthzSVNAccessFile /var/www/svn/authz  #访问权限控制文件
Require valid-user            #要求真实用户,不能匿名
</Location>
建立SVN Server仓库

通过如下命令建立svn仓库
创建仓库目录

[root@iZbp1hvbibqwiui44dxo6bZ /]# mkdir /var/www/svn

创建svn仓库 sungeek

[root@iZbp1hvbibqwiui44dxo6bZ /]# svnadmin create /var/www/svn/sungeek
[root@iZbp1hvbibqwiui44dxo6bZ /]# ls /var/www/svn/sungeek
conf  db  format  hooks  locks  README.txt
[root@iZbp1hvbibqwiui44dxo6bZ /]# chown -R apache.apache /var/www/svn

创建用户文件passwd和权限控制文件authz

[root@iZbp1hvbibqwiui44dxo6bZ /]# touch /var/www/svn/passwd 
[root@iZbp1hvbibqwiui44dxo6bZ /]# touch /var/www/svn/authz
配置安装PHP 和 iF.SVNadmin

由于iF.SVNAdmin使用php写的,因此我们需要安装php

[root@iZbp1hvbibqwiui44dxo6bZ /]# yum install php -y

安装iF.SVNAdmin

[root@iZbp1hvbibqwiui44dxo6bZ /]# wget http://sourceforge.net/projects/ifsvnadmin/files/svnadmin-1.6.2.zip
[root@iZbp1hvbibqwiui44dxo6bZ /]# unzip iF.SVNAdmin-stable-1.6.2
[root@iZbp1hvbibqwiui44dxo6bZ /]# cp -r iF.SVNAdmin-stable-1.6.2/ /var/www/html/svnadmin
[root@iZbp1hvbibqwiui44dxo6bZ /]# rm -rf svnadmin-1.6.2.zip
[root@iZbp1hvbibqwiui44dxo6bZ /]# rm -rf iF.SVNAdmin-stable-1.6.2/
[root@iZbp1hvbibqwiui44dxo6bZ /]# cd /var/www/html
[root@iZbp1hvbibqwiui44dxo6bZ html]# chown -R apache.apache svnadmin
[root@iZbp1hvbibqwiui44dxo6bZ html]# cd /var/www/html/svnadmin
[root@iZbp1hvbibqwiui44dxo6bZ svnadmin]# chmod -R 777 data

启动服务

如果开启了防火墙, 需要开启httpd访问权限

[root@iZbp1hvbibqwiui44dxo6bZ /]# firewall-cmd --permanent --add-service=http
success
[root@iZbp1hvbibqwiui44dxo6bZ /]# firewall-cmd --permanent --add-service=https
success
[root@iZbp1hvbibqwiui44dxo6bZ /]# firewall-cmd --reload 
success
修改/etc/sysconfig/svnserve

通过查看文件/usr/lib/systemd/system/svnserve.service, 了解到svnserver的配置文件是/etc/sysconfig/svnserve

[root@iZbp1hvbibqwiui44dxo6bZ /]# vim /etc/sysconfig/svnserve

OPTIONS="-r /var/svn" 改为 OPTIONS="-r /var/www/svn"

# OPTIONS is used to pass command-line arguments to svnserve.
#
# Specify the repository location in -r parameter:
OPTIONS="-r /var/www/svn"
启动apache服务

启动apache服务

[root@iZbp1hvbibqwiui44dxo6bZ /]# systemctl start httpd.service

设置apache服务开机启动

[root@iZbp1hvbibqwiui44dxo6bZ /]# systemctl enable httpd.service

重启apache服务

[root@iZbp1hvbibqwiui44dxo6bZ /]# systemctl start httpd.service

启动webserver服务后,浏览器地址输入http://ip/svnadmin出现配置界面,输入下图中配置信息,输入每个配置信息可以点击旁边的Test测试是否输入正确,最后保存配置
在这里插入图片描述
在这里插入图片描述
友情提示:无论登录页还是进入页面右上角都可以切换为中文显示。
在这里插入图片描述

解决apache服务启动失败的问题

**注意:**启动apache服务可能出现多个问题,导致启动失败
就我的这次经验来看,一共解决了三个问题才使服务正常启动。
1.配置文件错误。
命令行输入如下

[root@iZbp1hvbibqwiui44dxo6bZ /]# systemctl start httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

按照提示键入

[root@iZbp1hvbibqwiui44dxo6bZ /]# systemctl status httpd.service

输出一大堆,完全看不出问题出现在哪里。

httpd.service - The Apache HTTP Server

   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)

   Active: failed(Result: exit-code) since Wed 2018-05-23 16:31:04 CST; 13s ago

     Docs: man:httpd.service(8)

  Process: 8267 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)

 Main PID: 8267 (code=exited, status=1/FAILURE)

   Status: "Reading configuration..."

于是查看系统日志

[root@iZbp1hvbibqwiui44dxo6bZ /]# cat /var/log/messagesca

找到启动apache的日志信息

Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ systemd: Starting The Apache HTTP Server...
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ httpd: [Tue Apr 23 21:00:15.300992 2019] [so:warn] [pid 21468] AH01574: module dav_svn_module is already loaded, skipping
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ httpd: [Tue Apr 23 21:00:15.301080 2019] [so:warn] [pid 21468] AH01574: module authz_svn_module is already loaded, skipping
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ httpd: AH00526: Syntax error on line 6 of /etc/httpd/conf.d/subversion.conf:
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ httpd: Invalid command '\xe3\x80\x80\xe3\x80\x80DAV', perhaps misspelled or defined by a module not included in the server configuration
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ systemd: httpd.service: main process exited, code=exited, status=1/FAILURE
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ kill: kill: cannot find process ""
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ systemd: httpd.service: control process exited, code=exited status=1
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ systemd: Failed to start The Apache HTTP Server.
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ systemd: Unit httpd.service entered failed state.
Apr 23 21:00:15 iZbp1hvbibqwiui44dxo6bZ systemd: httpd.service failed.

AH00526: Syntax error on line 6 of /etc/httpd/conf.d/subversion.conf: 说明配置文件的第六行有问题。

找到配置文件,发现中文注释忘记去掉。修改后再次启动

[root@iZbp1hvbibqwiui44dxo6bZ /]# systemctl start httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

还是报错

Apr 24 09:46:00 iZbp1hvbibqwiui44dxo6bZ systemd-logind: New session 3523 of user root.
Apr 24 09:46:00 iZbp1hvbibqwiui44dxo6bZ systemd: Started Session 3523 of user root.
Apr 24 09:46:05 iZbp1hvbibqwiui44dxo6bZ systemd-logind: Removed session 3523.
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ systemd: Starting The Apache HTTP Server...
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ httpd: [Wed Apr 24 09:46:18.667828 2019] [so:warn] [pid 9636] AH01574: module dav_svn_module is already loaded, skipping
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ httpd: [Wed Apr 24 09:46:18.667915 2019] [so:warn] [pid 9636] AH01574: module authz_svn_module is already loaded, skipping
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.16.53.56. Set the 'ServerName' directive globally to suppress this message
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ httpd: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ httpd: no listening sockets available, shutting down
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ httpd: AH00015: Unable to open logs
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ systemd: httpd.service: main process exited, code=exited, status=1/FAILURE
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ kill: kill: cannot find process ""
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ systemd: httpd.service: control process exited, code=exited status=1
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ systemd: Failed to start The Apache HTTP Server.
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ systemd: Unit httpd.service entered failed state.
Apr 24 09:46:18 iZbp1hvbibqwiui44dxo6bZ systemd: httpd.service failed.

发现两条错误信息

  • httpd: Could not reliably determine the server’s fully qualified domain name, using 172.16.53.56. Set the ‘ServerName’ directive globally to suppress this message

第一条错误说明 使用172.16.53.56无法可靠地确定服务器的完全限定域名。全局设置’ServerName’指令来禁止此消息

  • (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80.

第二条错误应该是由于端口被占用导致的

查看80端口使用:

[root@iZbp1hvbibqwiui44dxo6bZ log]# netstat -antlp | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      660/nginx: worker p

发现nginx占用了80端口,可以停止nginx,笔者选择修改apache的默认端口
指定ServerName 并 修改apache默认端口

[root@iZbp1hvbibqwiui44dxo6bZ /]# find / -name httpd
/run/httpd
/etc/sysconfig/httpd
/etc/logrotate.d/httpd
/etc/httpd
/var/cache/httpd
/var/log/httpd
/usr/share/httpd
/usr/lib64/httpd
/usr/sbin/httpd
/usr/libexec/initscripts/legacy-actions/httpd
[root@iZbp1hvbibqwiui44dxo6bZ /]# cd /etc/httpd
[root@iZbp1hvbibqwiui44dxo6bZ httpd]# ll
total 12
drwxr-xr-x 2 root root 4096 Apr 24 10:06 conf
drwxr-xr-x 2 root root 4096 Apr 24 10:53 conf.d
drwxr-xr-x 2 root root 4096 Apr 23 20:42 conf.modules.d
lrwxrwxrwx 1 root root   19 Apr 23 20:20 logs -> ../../var/log/httpd
lrwxrwxrwx 1 root root   29 Apr 23 20:20 modules -> ../../usr/lib64/httpd/modules
lrwxrwxrwx 1 root root   10 Apr 23 20:20 run -> /run/httpd
[root@iZbp1hvbibqwiui44dxo6bZ httpd]# cd conf
[root@iZbp1hvbibqwiui44dxo6bZ conf]# ll
total 28
-rw-r--r-- 1 root root 11750 Apr 24 10:06 httpd.conf
-rw-r--r-- 1 root root 13077 Nov  5 09:47 magic
[root@iZbp1hvbibqwiui44dxo6bZ conf]# vim httpd.conf

找到serverName ,打开注释,并改为 localhost:5555
在这里插入图片描述
找到Listen 80 修改为 Listen 5555
在这里插入图片描述
再次启动

[root@iZbp1hvbibqwiui44dxo6bZ conf]# systemctl start httpd.service

防火墙开放5555端口

[root@iZbp1hvbibqwiui44dxo6bZ conf]# firewall-cmd --zone=public --add-port=5555/tcp --permanent
[root@iZbp1hvbibqwiui44dxo6bZ conf]# firewall-cmd --complete-reload

浏览器地址输入http://ip/svnadmin ,成功!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值