因为环境的迁移,我们将SVN由CentOS 6.8迁移至CentOS 7.3,原先的httpd-2.2.15已经升级为httpd-2.4.6,通过yum安装httpd mod_auth_mysql在CentOS 7.3已经不支持了。
1.环境准备
[root@Web245 ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@Web245 ~]# uname -an Linux Web245 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux [root@Web245 ~]# yum -y install httpd httpd-devel mariadb mariadb-libs mariadb-devel subversion mod_dav_svn mod_ssl patch
2.文件下载及准备
mod_auth_mysql项目地址
https://sourceforge.net/projects/modauthmysql
apache22.diff补丁地址
https://sourceforge.net/p/modauthmysql/patches/7/
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/_discuss/thread/efda3a06/c5a7/attachment/apache22.diff
3.mod_auth_mysql编译及安装
tar zxf mod_auth_mysql-3.0.0.tar.gz cd mod_auth_mysql-3.0.0 #对模块打补丁 patch -p0 < ../apache22.diff
修改源码
908行:由[return r->connection->remote_ip;]变为[return r->connection->client_ip;]
1273行: 由[const apr_array_header_t *reqs_arr = ap_requires(r);]变为[const apr_array_header_t *reqs_arr = apr_table_elts(r->headers_in);]
sed -i ‘s#return r->connection->remote_ip;#return r->connection->client_ip;#g‘ mod_auth_mysql.c sed -i ‘s#ap_requires(r)#apr_table_elts(r->headers_in)#g‘ mod_auth_mysql.c
编译
apxs -c -L/usr/lib64/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c
若出现以下错误
/usr/bin/ld: cannot find -lmysqlclient
collect2: error: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
则可能是路径指错了
apxs -c -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c
修改以上红色部分为/usr/lib64/mysql即可
安装
apxs -i mod_auth_mysql.la
################################################################
以上补丁部分也可以直接使用apache2.4的补丁
https://sourceforge.net/p/modauthmysql/patches/13/
本文出自 “枫林晚” 博客,请务必保留此出处http://fengwan.blog.51cto.com/508652/1898048
CentOS 7下httpd-2.4.6的mod_auth_mysql安装及配置
原文:http://fengwan.blog.51cto.com/508652/1898048