Wednesday, May 5, 2010

Step by Step Installing mod_security from Source in Linux Centos5.4, Fedora12 Howto

To Install mod Security from the source go to the Website of Mod security and download the packages
[superuser@ashwin modse]# get http://www.modsecurity.org/download/modsecurity-apache_2.5.12.tar.gz

--2010-05-05 15:19:12-- http://www.modsecurity.org/download/modsecurity-apache_2.5.12.tar.gz

Saving to: `modsecurity-apache_2.5.12.tar.gz'

100%[=======================================>] 1,392,209 1235.9Mb/s in 5s

2010-05-05 15:19:18 (1235.7 MB/s) - `modsecurity-apache_2.5.12.tar.gz' saved [1392209/1392209]

[superuser@ashwin modse]# tar -zxf modsecurity-apache_2.5.12.tar.gz
[superuser@ashwin modse]# cd modsecurity-apache_2.5.12

Stop Apache httpd
[superuser@ashwin modse]# service httpd stop
[superuser@ashwin apache2]# /configure --with-apxs=/path/to/httpd-2.x.y/bin/apxs

Compile with:
[superuser@ashwin apache2]# make

Optionally test with:
[superuser@ashwin apache2]# make test

Optionally build the ModSecurity Log Collector with:
[superuser@ashwin apache2]# make mlogc

Install the ModSecurity module with:
[superuser@ashwin apache2]# make install

If you get the below error you need to recompile apache with DSO and APXS

configure: looking for Apache module support via DSO through APXS
configure: error: couldn't find APXS

Solution
[superuser@ashwin modse]# get http://apache.siamwebhosting.com/httpd/httpd-2.2.15.tar.gz
[superuser@ashwin modse]# cd httpd-2.2.15
[superuser@ashwin httpd-2.2.15]# ./configure --enable-so --with-pcre
[superuser@ashwin httpd-2.2.15]# make
[superuser@ashwin httpd-2.2.15]# make install

Now Change you directory to /your/path/mod-security/apache2/
Install MOD-Security
[superuser@ashwin apache2]# make install

Congratulation you have successfully installed mod-security now to make it work add the following lines in your apache configuration file
[superuser@ashwin apache2]# vi /etc/httpd/conf/httpd.conf
LoadFile /usr/lib/libxml2.so
LoadFile /usr/lib/liblua5.1.so

# Load the ModSecurity module with:
LoadModule security2_module modules/mod_security2.so

Now Restart Apache Service and you ready to Go
superuser@ashwin apache2]# service httpd start

No comments:

Post a Comment