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 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
<IfModule security2_module>
# 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
</IfModule>
(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 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