ubuntu下apache2.4.6整合限速模块mod_bw.c 和报错的处理
首先,下载mod_bw.c 模块。下载地址:http://legacy.ivn.cl/files/source/mod_bw-0.8.tgz
下载后tar xzvf mod_bw-0.8.tgz进行解压。
这里要安装一个apache2开发模块,不然会报错。
执行apt install apache2-dev 安装。
安装完毕后,执行apxs2 -i -a -c mod_bw.c 开始安装mod_bw模块了。这个时候会报错如下:
/usr/share/apr-1.0/build/libtool --mode=compile --tag=disable-static x86_64-linux-gnu-gcc -prefer-pic -pipe -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -DBUILD_DATETIME='"2019-10-08T13:31:25"' -Wdate-time -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/apache2 -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include -c -o mod_bw.lo mod_bw.c && touch mod_bw.slo
libtool: compile: x86_64-linux-gnu-gcc -pipe -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -DBUILD_DATETIME=\"2019-10-08T13:31:25\" -Wdate-time -D_FORTIFY_SOURCE=2 -DLINUX -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/apache2 -I/usr/include/apr-1.0 -I/usr/include/apr-1.0 -I/usr/include -c mod_bw.c -fPIC -DPIC -o .libs/mod_bw.o
mod_bw.c: In function 'get_bw_rate':
mod_bw.c:522:59: error: 'conn_rec {aka struct conn_rec}' has no member named 'remote_addr'
if (apr_ipsubnet_test(e[i].x.ip, r->connection->remote_addr)) {
^
mod_bw.c: In function 'get_maxconn':
mod_bw.c:611:59: error: 'conn_rec {aka struct conn_rec}' has no member named 'remote_addr'
if (apr_ipsubnet_test(e[i].x.ip, r->connection->remote_addr)) {
^
mod_bw.c: In function 'get_sid':
mod_bw.c:662:59: error: 'conn_rec {aka struct conn_rec}' has no member named 'remote_addr'
if (apr_ipsubnet_test(e[i].x.ip, r->connection->remote_addr)) {
^
apxs:Error: Command failed with rc=65536
这个错误是由于apache2.2 到2.4 api有所改变,详细如下:
http://httpd.apache.org/docs/2.4/developer/new_api_2_4.html
解决办法:
vi mod_bw.c
把所有的remote_ip和remote_addr分别替换成client_ip和client_addr
再执行 apxs2 -i -a -c mod_bw.c 安装成功。