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 127.0.0.1 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 127.0.0.1 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

Cd/usr/share/modsecurity-crs/activated_rules/

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
Vim/etc/apache2/mod-available/security2.conf

Modify

# Default Debian dir for modsecurity's persistent data
SecDataDir/var/cache/modsecurity
# 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
‍‍Vim/etc/apache2/mod-available/mod-security.conf‍‍

Modify
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 http://www.linuxidc.com/Linux/2010-10/29027.htm?

Several highlights of http://www.linuxidc.com/Linux/2015-01/111914.htm 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://www.linuxidc.com/Linux/2013-06/86250.htm

Compile and install LAMP (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm in CentOS 5.9

Source code construction of Web Server Architecture in RedHat 5.4 LAMP environment and application PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP source environment to build WEB Server Linux + Apache + MySQL + PHP http://www.linuxidc.com/Linux/2013-05/84882.htm

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-01/112377.htm

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: info-contact@alibabacloud.com 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.