We need to minimize the information we are sharing with everyone. Also, we need to look over what modules are running and interacting with what applications. The bulk of the work is really in this procedure. It does not just involve turning on or off modules; but instead heavy tweaking the modules behavior and function can really harden a system beyond a hackers reach from the Internet.
a2enmod (module name)
a2dismod (module name)
apachectl -M
a2enmod ssl headers rewrite expires proxy proxy_fcgi proxy_http http2 cache cache_socache socache_shmcb php5
a2ensite /etc/apache2/sites-available/EXAMPLE_com_ssl.conf
a2ensite /etc/apache2/sites-available/EXAMPLE_com.conf
Do not forget to handle the IP defaulting to a web page if you disable the defaults. Do not use the Apache2 default page!
a2dissite /etc/apache2/sites-enabled/000-default.conf
a2dissite /etc/apache2/sites-enabled/default-ssl.conf
nano /etc/apache2/apache2.conf
Timeout 30
KeepAliveTimeout 5
<Directory /> <--- Protect our system files - If you did not add this in the prior Step2b, you can add it globally here
Require all denied
AllowOverride None
Options None
</Directory>
We could put all of Security Header settings in this file, but I highly do not recommend it on a Server that hosts numerous sites!
nano /etc/apache2/conf-enabled/security.conf
ServerTokens Prod
ServerSignature Off
TraceEnable Off
nano /etc/php5/apache2/php.ini
expose_php = Off
Each process under event can contain multiple threads and each is capable of more than one task. This results in Apache having the lowest requirements when used with mpm_event.
We are using a configuration that requires us to address the higher load requirements.
nano /etc/apache2/mods-enabled/mpm_event.conf
Config for a dedicated Web application server. If this a Web server, email, DNS, and so forth, cut everything in half and MaxMemFree minimum of 4096 - Which is 4 megs and alter as necessary.
<IfModule mpm_event_module>
#StartServers 5
#MinSpareServers 5
#MaxSpareServers 10
#MaxRequestWorkers 150
#MaxConnectionsPerChild 0
MaxMemFree 0
StartServers 5
MinSpareServers 15
MaxSpareServers 30
ServerLimit 32
MaxClients 256
MaxRequestWorkers 50
MaxConnectionsPerChild 1000
</IfModule>
systemctl restart apache2