Install Apache + ModSecurity in Ubuntu 14.04

Source: Internet
Author: User
Tags modsecurity

Install Apache + ModSecurity in Ubuntu 14.04

Platform: Ubuntu 14.04

Step 1: install apache

It is recommended that you use apt-get to install Apache, so that many libraries are supported !!!! If it is not too troublesome, you can use the source code for installation.

Enter apt-get install apache2

Update the apt-get install update package if you are prompted that this package does not exist.

After this step is installed, apache can provide services. Input to access the local website.

Step 2: Install modsecurity

This is also the same as the above, use

Apt-get install libxml2 libxml2-dev libxml2-utils libaprutil1 libaprutil1-dev libapache2-modsecurity

After installation, you can view the version number of your modsecurity.

Dpkg-s libapache2-modsecurity | grep Version

Step 3 configure modsecurity

Service apache2 reload

After the command takes effect, the modsecurity log File modsec_audit.log is generated in the/var/log/apache2/directory.

Use modsecurity core rule set

Place the rule set we remember in the following directory


Select enable base Rule Set

For f in $ (ls ../base_rules/); do ln-s ../base_rules/$ f; done

Modify the configuration of the apache module and enable the rule set.

Note: configuration files of modsecurity 2.7 and 2.6 are different.

(1) version 2.7

<IfModule security2_module>
# Default Debian dir for modsecurity's persistent data
# Include all the *. conf files in/etc/modsecurity.
# Keeping your local configuration in that directory
# Will allow for an easy upgrade of THIS file and
# Make your life easier
IncludeOptional/etc/modsecurity/*. conf
IncludeOptional/usr/share/modsecurity-crs/*. conf
IncludeOptional/usr/share/modsecurity-crs/activated_rules/*. conf

(2) version 2.6

Include/etc/modsecurity/*. conf
Include/usr/share/modsecurity-crs/*. conf
Include/usr/share/modsecurity-crs/activated_rules/*. conf

Start the modsecurity Module

A2enmod headersa2enmod security2 (version 2.6: a2enmod mod-security) service apache2 restart

Note !!!!!!!!!!!!!!
Once the IP address is modified, the error 403 is displayed !!!!!! For this error, after one day, it is impossible to search for various 403 errors on the Internet. Why ????
View errol. log and you will find that IP access is prohibited in modsecurity !!!!!! Use localhost to access the instance...
Therefore, reading logs is a very important thing.

------------------------------------- I am a split line -------------------------------------

How to enable Apache Rewrite in Ubuntu

Key points after upgrading Apache 14.04 to 2.2 in Ubuntu 2.4

Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04

Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)

Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind

Build a WEB Server Linux + Apache + MySQL + PHP in the LAMP source code Environment

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.