博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS7下Apache2.4.6使用MySQL5.7验证
阅读量:6858 次
发布时间:2019-06-26

本文共 2730 字,大约阅读时间需要 9 分钟。

由于环境新升级到了CentOS 7,Apache 2.4.6已经不支持mod_auth_mysql进行验证,我们主要通过MySQL验证SVN账号密码。

1
yum -y 
install 
httpd httpd-devel mod_dav_svn mod_ssl apr-util-mysql

1.使用dbd进行认证,无法与其他工具进行集成,比如Zabbix,禅道(将密码md5加密存储)

1
2
3
4
5
6
7
8
9
10
11
12
13
DBDriver mysql
DBDParams 
"host=192.168.0.75 port=3306 dbname=svn user=test password=test"
DBDMin 1
DBDKeep 2
DBDMax 10
DBDExptime 60
 
<Location 
"/"
>
AuthType Basic
AuthName 
"SVN Auth"
AuthBasicProvider dbd
AuthDBDUserPWQuery 
"select password from account where is_enable =1 and user = %s"
<
/Location
>

数据库则为

> select * from user;

+----+-------+-------------------------------------------+-----------+

| id | user  | password                                                     | is_enable  |

+----+-------+-------------------------------------------+-----------+

|  4 | test  | {SHA}qUqP5cyxm6YcTAhz05Hph5gvu9M= |         1      |

+----+-------+-------------------------------------------+-----------+

以上只有test账号可以正常使用,其他明文密码和直接md5加密是无法使用的

密码的生成有以下几种加密方式,把以下的密码插入数据库

1
2
3
4
5
6
7
8
9
10
11
12
-- bcrypt
$ htpasswd -nbB myName myPassword
myName:$2y$05$c4WoMPo3SXsafkva.HHa6uXQZWr7oboPiC2bT
/r7q1BB8I2s0BRqC
-- MD5
$ htpasswd -nbm myName myPassword
myName:$apr1$r31.....$HqJZimcKQFAMYayBlzkrA/
-- SHA1
$ htpasswd -nbs myName myPassword
myName:{SHA}VBPuJHI7uixaa6LQGWx4s+5GKNE=
-- CRYPT
$ htpasswd -nbd myName myPassword
myName:rqXexS6ZhobKA

2.手动安装mod_auth_mysql

下载软件包及补丁

1
2
wget https:
//nchc
.dl.sourceforge.net
/project/modauthmysql/modauthmysql/3
.0.0
/mod_auth_mysql-3
.0.0.
tar
.gz
wget https:
//sourceforge
.net
/p/modauthmysql/patches/13/attachment/mod_auth_mysql_3
.0.0_patch_apache2.4.
diff

安装依赖包:

1
yum -y 
install 
mariadb-libs mariadb maraidb-devel patch

安装模块及配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# tar zxf mod_auth_mysql-3.0.0.tar.gz
# cd mod_auth_mysql-3.0.0
# patch -p0 < ../mod_auth_mysql_3.0.0_patch_apache2.4.diff
can't 
find 
file 
to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- mod_auth_mysql-3.0.0
/mod_auth_mysql
.c      2005-06-22 12:17:45.000000000 -0400
|+++ mod_auth_mysql-3.0.0_patch_apache_2.4
/mod_auth_mysql
.c     2013-12-30 18:07:27.646704470 -0500
--------------------------
File to patch: mod_auth_mysql.c        
#此处输入mod_auth_mysql.c执行即可
patching 
file 
mod_auth_mysql.c
 
编译模块:
# apxs -c -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c
 
安装模块:
# apxs -i mod_auth_mysql.la

最后在httpd.conf末尾增加配置文件

LoadModule mysql_auth_module modules/mod_auth_mysql.so

检查是否报错:

httpd -t

以上在正常情况下是这样的,但是5.7的就会报错,必须安装如下几个包:

mysql-community-libs-compat

mysql-community-libs

mysql-community-client

mysql-community-common

如果遇上错误,则可以在未安装5.7的机器上使用yum安装的mariadb-libs进行编译,然后上传到5.7的机器,测试后发现无任何问题。

本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1979922

转载地址:http://bfiyl.baihongyu.com/

你可能感兴趣的文章
如何根据指定软件版本制作属于自己的puppet yum源
查看>>
Linux下架设rsync服务器
查看>>
Struts2教程8:拦截器概述
查看>>
windows 屏幕坐标 窗口坐标 客户区坐标 逻辑坐标 设备坐标之间的关系及转换
查看>>
在Foreda8上试安装Apchehttpd-2.4.6.tar.gz
查看>>
基于S3C2410的VIVI移植
查看>>
Entity Framwork one to one problem
查看>>
[转] Attach、Detach和DeleteObject
查看>>
[转] C# 获取程序运行目录
查看>>
【OpenCV学习】极坐标变换
查看>>
[Android Pro] InputStream.skip方法的思考
查看>>
判断页面加载
查看>>
8年前,《西班牙,我为你哭泣。》
查看>>
SVN:服务器资源删掉,本地添加时和删掉的名字同名出现One or more files are in a conflicted state....
查看>>
MySQL数据库遭到攻击篡改---使用备份和binlog进行数据恢复
查看>>
如何在Java中定义常量(Constant)
查看>>
Windows 8实用窍门系列:8.Windows 8 中Slider控件和ToggleSwitch控件
查看>>
在IIS 7.0中架设网站,并用VS2005来调试Web项目
查看>>
白话学习MVC(七)Action的执行一
查看>>
javaweb学习总结(四)——Http协议
查看>>