Apache安装ModSecurity和CRS

安装过程都是从官网上扒下来的(如果觉得我写的不够好,可以直接根据官网部署),官网地址:http://www.modsecurity.org/

全篇分为两个部分:
1、安装ModSecurity
2、添加CRS规则


先决条件
ModSecurity 2.x仅适用于Apache 2.0.x或更高版本

1、mod_uniqueid
确保你已经mod_unique_id安装。mod_unique_id与Apache httpd一起打包。

2、libapr和libapr-util
libapr和libapr-util - http://apr.apache.org/

3、libpcre
http://www.pcre.org/

4、libxml2
http://xmlsoft.org/downloads.html

5、liblua v5.xx
这个库是可选的,只有当你使用新的Lua引擎时才需要 - http://www.lua.org/download.html

注意:ModSecurity需要动态库。这些默认情况下不会在源代码安装中生成,因此建议使用二进制安装。
注意:libModSecurity(aka v3)与Lua 5.2+兼容。
libcurl v7.15.1或更高版本
如果您将使用ModSecurity日志收集器(mlogc)将审计日志发送到中央存储库,则还需要使用curl库。
http://curl.haxx.se/libcurl/

注意:许多libcurl与SSL / TLS支持的GnuTLS库链接有问题。建议将openssl库用于libcurl中的SSL / TLS支持。

GIT安装方法

在开始安装之前,您需要选择您的首选安装方法。首先,您需要选择是否直接从git(最好的功能,但可能不稳定)安装最新版本的ModSecurity,或使用最新的稳定版本(推荐)。如果您选择稳定版本,则可以从二进制文件安装ModSecurity。什么情况都可以从源代码编译它。

1、GitHub访问
如果你想访问最新版本的模块,你需要从git仓库获取它。自上次稳定版本以来所做的更改通常在网站(以及文件CHANGES)中提供。ModSecurity的git存储库由GitHub(http://www.github.com)托管。您可以直接访问它,或通过使用此地址的网页查看:https://github.com/SpiderLabs/ModSecurity

要将最新的TRUNK源代码下载到您的计算机上,您需要执行以下命令:

$ git clone git://github.com/SpiderLabs/ModSecurity.git 
$ git checkout remotes/trunk

对于v2.6.0及以上版本,安装过程已经改变。按着这些次序:

1.cd进入目录 - $cd ModSecurity
2.运行autogen.sh脚本 - $./autogen.sh
3.运行配置脚本 - $./configure
4.运行make - $make
5.运行make install - $make install
6.将新的mod_security2.so文件复制到适当的Apache模块目录中
$cp /usr/local/modsecurity/lib/mod_security2.so /usr/local/apache/modules/

稳定版本下载

Installation - Fedora/CentOS

$ sudo yum install -y mod_security
$ sudo /etc/init.d/httpd restart

注:更多版本,安装方式,请访问http://www.modsecurity.org/download.html

源码安装步骤

  • 停止Apache httpd
  • 解压缩ModSecurity存档
  • 安装

运行configure脚本来生成一个Makefile。通常不需要任何选项。

./configure

选项可用于更多自定义(使用./configure –help获取完整列表),但通常您只需指定由Apache httpd使用–with-apxs选项安装的apxs命令的位置。

./configure --with-apxs=/path/to/httpd-2.x.y/bin/apxs

注意:某些配置选项是用于调试其他开发用途的。如果启用,这些选项可能会显着影响性能。这些选项包括所有–debug- *选项以及–enable-performance-measurements选项。

编译

make && make install

加载ModSecurity模块:

LoadModule security2_module modules / mod_security2.so

启动Apache就可以了


同样,安装CRS规则请访问GitHub:https://github.com/SpiderLabs/owasp-modsecurity-crs/blob/v3.0/master/INSTALL

猜你喜欢

转载自blog.csdn.net/leo15561050003/article/details/79174084