HOWTO ModSecurity2 under Apache2 (centos4/customapache)

erohas

Verified User
Joined
Aug 5, 2007
Messages
40
Location
Kazakhstan, Almaty
Download Httpd Source for special.mk (Build)
Code:
wget http://apache.ziply.com/httpd/httpd-2.0.61.tar.bz2
tar jxvf httpd-2.0.61.tar.bz2
cd httpd-2.0.61
Than copy "Configure" options in "/usr/local/directadmin/customapache/configure.ap_2"
and run
Code:
./configure <<<copied options>>>
make
cd ..
than get latest modsecurity source
Code:
wget http://www.modsecurity.org/download/modsecurity-apache_2.1.4.tar.gz
tar zxvf modsecurity-apache_2.1.4.tar.gz
cd modsecurity-apache_2.1.4
Edit Makefile
Code:
cd apache2/
vi Makefile
and replace
Code:
top_dir = ../../httpd-2.0.61
INCLUDES = -I /usr/include/libxml2 -I ../../httpd-2.0.61/srclib/pcre
than run make
Code:
make && make install
now edit httpd.conf
Code:
vi /etc/httpd/conf/httpd.conf
and insert the following
Code:
LoadFile /usr/lib/libxml2.so
LoadModule security2_module     /usr/lib/apache/mod_security2.so
<IfModule mod_security2.c>
Include conf/modsec/*.conf
</IfModule>
then:
Code:
mkdir /etc/httpd/conf/modsec
cd /etc/httpd/conf/modsec
wget http://www.modsecurity.org/download/modsecurity-core-rules_2.1-1.5.1.tar.gz
tar zxvf modsecurity-core-rules_2.1-1.5.1.tar.gz
/etc/init.d/httpd restart

that howto works for me!

and finally edit conf files in /etc/httpd/conf/modsec for your needs

Russian translation located here
 
Last edited:
make && make install
after this step i got this:

Code:
In file included from modsecurity.h:35,
                 from mod_security2.c:16:
msc_pcre.h:16:18: pcre.h: No such file or directory
make: *** [mod_security2.slo] Error 1
 
after this step i got this:

Code:
In file included from modsecurity.h:35,
                 from mod_security2.c:16:
msc_pcre.h:16:18: pcre.h: No such file or directory
make: *** [mod_security2.slo] Error 1

top_dir = ../../httpd-2.0.61
INCLUDES = -I /usr/include/libxml2 -I ../../httpd-2.0.61/srclib/pcre
 
Hi There!

Thank you so much for posting this tutorial. I've been searching for days to find a tutorial that is designed for the directadmin installation of apache.

My installation of your instructions went flawlessly. However, after I was done I ran #service httpd stop and # service httpd start. I got this error message here:

httpd: Syntax error on line 178 of /etc/httpd/conf/httpd.conf: Cannot load /usr/lib/libxml2.so into server: /usr/lib/libxml2.so: wrong ELF class: ELFCLASS32

I don't know why, and if you could help, I would greatly appreciate it!

Thanks.

PS - I didn't follow the first step (the special.mk installation) because that file was already there. My vps provider installed apache for me (v. 2.2.6)
 
It looks as if you've installed a 32-bit module into a 64-bit copy of apache.

Jeff
 
Back
Top