日期:2014-05-16  浏览次数:20776 次

制作适用于apache 2.4的mod_auth_mysql3

自己制作适用于Apache 2.4的mod_auth_mysql3的背景是,Web服务器的apache httpd server从2.2升级

为2.4以后,以前使用的mod_auth_mysql已经无法使用。由于2.4相对于2.2来说,内部核心代码有了一定的变化,使得mod_auth_mysql.c文件无法编译成所需的mod_auth_mysql.so文件。同时在网上也没有找到相应的解决方案。自己通过比较mod_auth_mysql.c使用apache 2.2的源代码和对应apache 2.4的源代码,制作出了适合apache 2.4的mod_auth_mysql3,并测试通过。下面是制作步骤:

?

1、 从http://sourceforge.net/projects/modauthmysql下载mod_auth_mysql-3.0.0.tar.gz和apache22.diff。

2、在Linux下,用 tar -zxvf mod_auth_mysql-3.0.0.tar.gz命令解压缩mod_auth_mysql3。

3、用cd ?mod_auth_mysql-3.0.0命令进入解压后的mod_auth_mysql-3.0.0目录。

4、复制apache22.diff文件到包含mod_auth_mysql.c的目录下,执行

? ? patch -p0 < apache22.diff

? ? 对mod_auth_mysql.c打支持apache 2.2的patch。

5、修改打完patch的mod_auth_mysql.c文件,使其能够在apache 2.4下编译成功。

? ?修改内容如下:

? ?

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);]

?

6、用下面命令编译mod_auth_mysql.c文件

?apxs -c -L/usr/lib/mysql -I/usr/include/mysql -lmysqlclient -lm -lz mod_auth_mysql.c

?

7、用下面命令生成mod_auth_msyql.so文件,并把该文件安装到apache 2.4的modules目录下

?apxs -i mod_auth_mysql.la

?

?