Modsecurityのインストール要件を確認し、インストールしてみました。その手順を備忘としてまとめました。
下記リファレンスマニュアルを参考にしました。
https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#Introduction
(1)ModSecurityのApacheへのインストール要件
①Apache2.0.x以上、Apache2.2.x以上推奨
②mod_unique_idが必要
・CentOS6.4のApacheパッケージには、有効になってはいませんでしたがインストールはされていました。
$ yum provides "*/mod_uniq*" : httpd-2.2.15-29.el6.centos.x86_64 : Apache HTTP Server Repo : base Matched from: Filename : /usr/lib64/httpd/modules/mod_unique_id.so
③libaprとlibapr-utilが必要
http://apr.apache.org/
私の環境ではインストール済みでした。
$ rpm -qa | grep apr apr-util-ldap-1.3.9-3.el6_0.1.x86_64 apr-1.3.9-5.el6_2.x86_64 apr-util-1.3.9-3.el6_0.1.x86_64 apr-devel-1.3.9-5.el6_2.x86_64 apr-util-devel-1.3.9-3.el6_0.1.x86_64
④libpcreが必要
http://www.pcre.org/
私の環境ではインストール済みでした。
Installed Packages
Name : pcre
Arch : x86_64
Version : 7.8
Release : 6.el6
Size : 514 k
Repo : installed
From repo : base
Summary : Perl-compatible regular expression library
URL : http://www.pcre.org/
License : BSD
Description : Perl-compatible regular expression library.
: PCRE has its own native API, but a set of "wrapper" functions that
: are based on the POSIX API are also supplied in the library
: libpcreposix. Note that this just provides a POSIX calling
: interface to PCRE: the regular expressions themselves still follow
: Perl syntax and semantics. The header file for the POSIX-style
: functions is called pcreposix.h.
⑤libxml2が必要
http://xmlsoft.org/downloads.html
私の環境ではインストール済みでした。
Installed Packages
Name : libxml2
Arch : x86_64
Version : 2.7.6
Release : 12.el6_4.1
Size : 1.7 M
Repo : installed
From repo : updates
Summary : Library providing XML and HTML support
URL : http://xmlsoft.org/
License : MIT
Description : This library allows to manipulate XML files. It includes support
: to read, modify and write XML and HTML files. There is DTDs
: support this includes parsing and validation even with complex
: DtDs, either at parse time or later once the document has been
: modified. The output can be a simple SAX stream or and in-memory
: DOM like representations. In this case one can use the built-in
: XPath and XPointer implementation to select subnodes or ranges. A
: flexible Input/Output mechanism is available, with existing HTTP
: and FTP modules and combined to an URI library.
(2)CentOS 5.10にyumでmod_securityをインストール
①yumでepelリポジトリを使えるようにする
こちらを参照
②yumでインストール
# yum --enablerepo=epel install mod_security Installed: mod_security.i386 0:2.6.8-4.el5 Dependency Installed: lua.i386 0:5.1.4-4.el5 Complete!
(3)初期設定
①libxml2.soとliblua5.1.soのパスを確認
# rpm -ql lua : /usr/lib/liblua-5.1.so # rpm -ql libxml2 : /usr/lib/libxml2.so.2 /usr/lib/libxml2.so.2.6.26
②Apache設定ファイルに各モジュールのロードを追加
# vi/etc/httpd/conf.d/mod_security.conf security2_moduleのロードの前にlibxml2.soとliblua5.1.soのロードを追加 LoadFile /usr/lib/libxml2.so.2.6.26 LoadFile /usr/lib/liblua-5.1.so LoadModule security2_module modules/mod_security2.so LoadModule unique_id_module modules/mod_unique_id.so
③CRSをインストール
# yum --enablerepo=epel install mod_security_crs Installed: mod_security_crs.noarch 0:2.2.5-5.el5 Complete!
/etc/httpd/modsecurity.d/activated_rules/ディレクトリ内にルールセットがインストールされます。
関連記事の目次