本文共 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/