CentOS7下Apache2.4.6使用MySQL5.7验证

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

由于环境新升级到了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


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
17天前
|
关系型数据库 MySQL Linux
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
linux CentOS 7.4下 mysql5.7.20 密码改简单的方法
20 0
|
1月前
|
Java Linux
Flume【环境搭建 01】CentOS Linux release 7.5 安装配置 apache-flume-1.9.0 并验证
【2月更文挑战第16天】Flume【环境搭建 01】CentOS Linux release 7.5 安装配置 apache-flume-1.9.0 并验证
34 0
|
10天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
60 2
|
17天前
|
Linux Apache
CentOS 7 源码安装LAMP环境源 和apache监听别的端口
CentOS 7 源码安装LAMP环境源 和apache监听别的端口
13 0
|
17天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
76 0
|
存储 关系型数据库 MySQL
【MYSQL】—— MySQL 在 Centos 7环境安装
【MYSQL】—— MySQL 在 Centos 7环境安装
|
1月前
|
关系型数据库 MySQL Linux
【VMware安装+centos 7Linux系统+MySQL安装】——在Linux系统中安装MySQL步骤,以及遇见的各种问题(如:vm两个虚拟网卡消失、vm网络适配器有感叹号等等)
【VMware安装+centos 7Linux系统+MySQL安装】——在Linux系统中安装MySQL步骤,以及遇见的各种问题(如:vm两个虚拟网卡消失、vm网络适配器有感叹号等等)
185 0
|
3天前
|
SQL 存储 关系型数据库
MySQL Cluster集群安装及使用
MySQL Cluster集群安装及使用
|
18天前
|
关系型数据库 MySQL 数据库
mysql卸载、下载、安装(window版本)
mysql卸载、下载、安装(window版本)
|
7天前
|
关系型数据库 MySQL 数据库
《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
29 4