Check for the current version of apache installed on the server and make sure that the apache development tools have been installed on the server (i.e. httpd-devel package) using the command
rpm -qa | grep httpd-devel
In case the apache development tools are not installed on the server, install the package via yum
yum install httpd-devel
The devel package is necessary for addition of extra modules to apache ( since apxs [apache extension tool] comes with httpd-devel. Before installation of mod_security, ensure that the c (apache module) is installed on the server as well. The command httpd -t -D DUMP_MODULES will provide a list of all loaded apache modules.
Use
httpd -t -D DUMP_MODULES | grep httpd -t -D DUMP_MODULES to check for the unique_id_module
If the unique_id_module is not installed, download the apache source package from http://httpd.apache.org/download.cgi (preferably the source file of current version of apache installed on the server) and use the command as below to add unique_id_module to apache
apxs -iac httpd-2.2.22/modules/metadata/mod_unique_id.c ( I installed unique_id_module for apache 2.2.22, in general the command can be modified as
apxs -iac /path/to/extracted/apache/source/modules/metadata/mod_unique_id.c )
Now download the latest version of mod_security from http://www.modsecurity.org/download/ and extract the contents of the archive.
Enter the directory with the extracted contents and run the command
./configure –with-apxs=/path/to/apxs
Use the command which apxs to check for the path of the apxs binary
Now run make and make install to build and install the module. After installation, add
LoadFile /usr/lib/libxml2.so
LoadFile /usr/lib/liblua5.1.so
LoadModule security2_module modules/mod_security2.so
to the apache configuration file ( httpd.conf usually present in /etc/httpd/conf/httpd.conf ) and restart apache.
Note:: Install lua package via yum if liblua5.1.so is not present in /usr/lib/ , also apache should be compiled with proxy proxy_http proxy_ftp proxy_connect (for enabling mod_proxy) for mod_security to work properly.
After installation mod_security can be suitably configured.
If you require help, contact SupportPRO Server Admin