How to Install mod_evasive in CPanel

install mod_evasive cpanel

mod_evasive is a useful Apache module that protects your website from malicious requests, DOS and DDOS attacks. It automatically keeps track of suspicious IPs and URLs and blocks traffic from them. It also automatically logs every incident and emails you. Let us take a look at how to install mod_evasive in CPanel.


How to Install mod_evasive in CPanel

Here are the steps to install mod_evasive in CPanel. We will be using Easy Apache 4 to install mod_evasive, since it makes the whole process very easy.

1. Open terminal or SSH into your Linux system

2. Run the following command

# sudo yum install ea-apache24-mod_evasive


That’s it! CPanel will automatically detect and block malicious traffic, without any additional configuration.


If you are using WHM web interface, then login as root and go to

WHM » Home » Software » EasyApache 4

Within Apache Modules section, select mod_evasive. You will see a set of prompts. Follow them to complete the installation.


If you are using Easy Apache 3, then here are the steps to install mod_evasive on Apache

1. Log into your Linux server as root, or open terminal window.


2. Go to /usr/local/src directory and download the source file for mod_evasive

cd /usr/local/src/
curl -Ls > /usr/local/src/mod_evasive.tar.gz


3. Extract the archive and go to its directory

tar xf mod_evasive.tar.gz
cd /usr/local/src/mod_evasive


4. Build from source using the following commands

$ /usr/local/apache/bin/apxs -i -a -c mod_evasive24.c

You will see output ending with

[activating module `evasive20' in /usr/local/apache/conf/httpd.conf]


5. Tell Apache to include mod_evasive configuration. For that, open Apache config file and look for”LoadModule evasive” and add the following line right after it

Include "/usr/local/apache/conf/includes/mod_evasive.conf"


6. Ensure that the above line is not removed when you re-build/upgrade the package, by distilling it

/usr/local/cpanel/bin/apache_conf_distiller --update

You will see the message “Distilled Successfully”


7. Next we add mod_evasive configuration.

sudo touch /usr/local/apache/conf/includes/mod_evasive.conf
sudo nano mod_evasive.conf


When the text editor opens, add the following lines

<IfModule mod_evasive20.c>
 DOSHashTableSize 3097
 DOSPageCount 2
 DOSSiteCount 50
 DOSPageInterval 1
 DOSSiteInterval 1
 DOSBlockingPeriod 3600
 DOSLogDir "/var/log/mod_evasive"


8. Make log directories

touch /var/log/mod_evasive


9. Test Apache configuration

/usr/local/apache/bin/apachectl configtest
Syntax OK


10. Restart Apache server



That’s it! mod_evasive is installed in Apache CPanel.


11. (Optional) If you want Apache to rebuild mod_evasive when it upgrades, run the following command

echo "/usr/local/apache/bin/apxs -i -a -c /usr/local/src/mod_evasive/mod_evasive24.c" >> /scripts/after_apache_make_install
chmod +x /scripts/after_apache_make_install





About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!