Install and configure ModSecurity in Apache

Source: Internet
Author: User
Tags php mysql modsecurity

1. install LAMP and the compiling environment # Apache 2.2.5 # Mysql 5.1.6 # install apache + php + mysql # yum-y install httpd php mysql-server php-mysql environment # yum install gcc make # yum install libxml2 libxml2-devel httpd-devel pcre-devel curl-devel start service test # service httpd start # service mysqld start note: iptables is required to allow all IP addresses to access port 80. 2. Install mod_security to download the source code from the official website, compile and install mod_security. // Sourceforge fuck gwf # wget # Tar xzf modsecurity-apache_2.6.6.tar.gz # cd modsecurity-apache_2.6.6 #. /configure # make install # cp modsecurity. conf-recommended/etc/httpd/conf. d/modsecurity. for conf3 and rule configuration, You need to configure some rules to prevent unknown vulnerabilities and scan. The Modsecurity recommendation rules and OWASP_CRS rules are combined as follows: The Detailed Rules adopt OWASP_CRS: Use Modsecurity recommendation rules to set basic rules: Add the content of the Modsecurity recommendation rule file to the front of modsecurity_crs_10_config.conf and change SecRuleEngine DetectionOnly to SecRuleEngine On (because it requires more than detection and defense ). # Cd/etc/httpd/# wget # Tar xzf modsecurity-crs_2.2.5.tar.gz # mv modsecurity-crs_2.2.5 modsecurity-crs # cd modsecurity-crs # cp modsecurity_crs_10_setup.conf.example modsecurity_crs_10_config.conf # vi/etc/httpd/modsecurity. d/modsecurity_crs_10_config.conf4. Load the module Apache to load the mod_security module. You must disable apache when modifying the module. # Vi/etc/httpd/conf/httpd. find the LoadModule In the conf file and add the following code: # LoadModule security2_module modules/ # LoadModule unique_id_module modules/ and then add the module configuration file? 1234567 & lt; IfModule security2_module & gt; Include/etc/httpd/modsecurity-crs/modsecurity_crs_10_config.conf Include/etc/httpd/modsecurity-crs/base_rules /*. conf & lt;/IfModule & gt; restart apache # service httpd restart5. For function testing, see the appendix. 6. CONCLUSION Through the above installation and testing, we found that modsecurity can defend against some attacks. At the same time, users can customize rules as needed. In terms of functionality, it is still very good, however, the rule configuration is relatively complex and requires in-depth research in practical application. References

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.