Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Install Mod_Security On Apache2.4 (Ubuntu 14.04)

Shulou Source: shulou.com Published: 2022-06-01 04:33:27 10月05日 Update

1.Installing Apache,PHP

Press ctrl+alt+T to to open terminal

Enter the following command

Sudo apt-get update

Sudo apt-get install apache2

Sudo apt-get install php5

Sudo / etc/init.d/apache2 restart

2.Installing Mod Security on Apache

Commands for installing dependency packages

Sudo apt-get install libxml2 libxml2-devlibxml2-utils

Sudo apt-get install libaprutil1libaprutil1-dev

64-bit Ubuntu runs the following command

Sudo ln-s/usr/lib/x86_64-linux-gnu/libxml2.so.2 / usr/lib/libxml2.so.2

Install mod security's command

Sudo apt-get install libapache-mod-security

3.Configuring ModSecurity Rules

Sudo mv/etc/modsecurity/modsecurity.conf-recommended / etc/modsecurity/modsecurity.conf

Start configuration

Sudo gedit/etc/modsecurity/modsecurity.conf

Find SecRuleEngine

Set SecRuleEngine to On.

SecRuleEngine On

4.Install the latest OWASP Rule Set

Cd / tmp

Sudo wget https://github.com/root25/MODSEC/raw/master/modsecurity-crs_2.2.5.tar.gz

Sudo tar-zxvf modsecurity-crs_2.2.5.tar.gz

Sudo cp-R modsecurity-crs_2.2.5/* / usr/share/modsecurity-crs/

Sudo rm modsecurity-crs_2.2.5.tar.gz

Sudo rm-R modsecurity-crs_2.2.5

Sudo mv / usr/share/modsecurity-crs/modsecurity_crs_10_setup.conf.example / usr/share/modsecurity-crs/modsecurity_crs_10_setup.conf

Add a rule set to an active rule set

Cd / usr/share/modsecurity-crs/base_rules

For f in *; do sudo ln-s / usr/share/modsecurity-crs/base_rules/$f/usr/share/modsecurity-crs/activated_rules/$f; done

Cd / usr/share/modsecurity-crs/optional_rules

For f in *; do sudo ln-s / usr/share/modsecurity-crs/optional_rules/$f/usr/share/modsecurity-crs/activated_rules/$f; done

Add it to apache mods:

Sudo gedit / etc/apache2/mods-available/security2.conf

Before joining, save and exit

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

IncludeOptional / etc/modsecurity/*.conf

# IncludeOptional/usr/share/modsecurity-crs/*.conf

# IncludeOptional/usr/share/modsecurity-crs/activated_rules/*.conf

Use headers module:

Sudo a2enmod headers

5.Final

Test whether mod_decurity is in normal use

Sudo a2enmod mod-security

Restart spache2

Sudo / etc/init.d/apache2 restart

6.testing

Visit URL: http://192.168.123.137:8080/?id=23' or '1subscription 1

7.Checking the Log

Detect mod_security log

Cd / var/log/apache2/

Sudo less modsec_audit.log

Tags: Commands rules testing testing input running configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn Apple Docker Huawei