How to install Mod Security

How to install Mod Security Using cPanel and DirectAdmin?

Today we will learn how to install mod security. There have two different systems for using mod security via cPanel or DirectAdmin. Below we discuss the system.

1. Mod security on cPanel

The ModSecurity configuration tools do nothing until the module is installed on Apache. If ModSecurity is not yet installed, it can be done with EasyApache. Make sure ModSecurity is selected before starting the build process.

Alternatively, if you are familiar with the CLI – you can log into your server as root and run the following command on a cPanel server with EasyApache 4.

Command: # [root@knownhost] yum install ea-apache24-mod_security2

This will install mod_security and its required rules to work

Once the build process is complete, the next step is to add a rule set. The recommended way to do this is through WHM at Home >> Security Center >> ModSecurity™ Vendors as described here. By default, there should be a cPanel-curated OWASP rule set to choose from. If there is a different published ruleset you prefer to use instead, check with the developer of the ruleset to see if they make their ruleset available as a vendor that can be added via WHM. If rulesets are available in this format, this is the strongly preferred method of installing rulesets.

2. Install mod security on DirectAdmin

Mod_security for DirectAdmin is installed over the CLI via custom builds, so it is recommended that you familiarize yourself with DirectAdmin and custom builds before continuing.

It is important to note that DirectAdmin offers two different rules – OWASP and Comodo. We will use ‘Comodo’ for the rules below.

Sign in to your DirectAdmin server as root and perform the following command:

  1. cd /usr/local/directadmin/custombuild
  2. ./build update
  3. ./build set modsecurity yes
  4. ./build set modsecurity_ruleset “comodo”
  5. ./build modsecurity
  6. ./build modsecurity_rules
  7. ./build rewrite_confs

This will run through the compilation process of mod_security on your server and for an active Directadmin installation. Once this is done you can sign in to DirectAdmin and use the ModSecurity interface at Server Manager >> ModSecurity (https://hostname:2222/admin/modsecurity).

It allows you to manage ModSecurity, check logs, customize its rules and perform various other administrative tasks. Read this article if you want to know about VPS: Linux VPS and Windows VPS.

Scroll to Top