Install Apache + ModSecurity under Ubuntu14.04

Source: Internet
Author: User
Tags modsecurity
Platform: Ubuntu14.04 Step 1: install apache. I suggest you install Apache with apt-get. This will reduce the number of libraries !!!! If it is not too troublesome, you can use the source code to install the input apt-getinstallapache2 if the prompt does not have this software package, update the software package apt-getinstallupdate. After this step is installed, apache can provide services, enter to access this

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


# 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 does Apache Rewrite in Ubuntu enable

Several highlights of after Apache 14.04 upgrade to 2.2 in Ubuntu 2.4

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

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

Source code construction of Web Server Architecture in RedHat 5.4 LAMP environment and application PHPWind

LAMP source environment to build WEB Server Linux + Apache + MySQL + PHP

For more information about Ubuntu, see Ubuntu special page Tid = 2

This article permanently updates the link address: Http://

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.