且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[WAF]apache和modsecurity的安装

更新时间:2022-09-19 21:55:35

安装pcre
安装apr
http://labs.renren.com/apache-mirror//apr/apr-1.4.5.tar.gz
./configure
make
make install
apache的安装
./configure   --with-included-apr --with-php --with-mysql --with-susexec --disable-info --with-mpm=prefork --enable-so --enable-cgi --enable-rewrite --enable-ssl --enable-mime-magic --enable-unique-id --enable-mods-shared=all --enable-ssl=shared  --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http
make
make install
注意 不要指定--prefix=/app/apache,否则出现error: cannot install `libaprutil-1.la' to a directory not ending in /usr/local/apache2/lib
因为编译使用了shared modules,必须添加LoadModule authz_host_module modules/mod_authz_host.so,否则出现 Invalid command 'Order', perhaps misspelled or defined by a module not included in the server config

验证apxs安装
/usr/local/apache2/bin/apxs -c -i


安装modsecurity
来源位置: http://cdnetworks-kr-1.dl.sourceforge.net/project/mod-security/modsecurity-apache/2.6.0/modsecurity-apache_2.6.0.tar.gz
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-pcre=/usr/local/bin/pcre-config --with-apr=/usr/local/apache2/bin/apr-1-config --with-apu=/usr/local/apache2/bin/apu-1-config
make
make install

创建目录modsecurity
mkdir      /usr/local/apache2/conf/modsecurity/
修改httpd.conf
加入
LoadFile /usr/lib/libxml2.so
LoadModule unique_id_module modules/mod_unique_id.so
LoadModule security2_module modules/mod_security2.so