What are modules in apache sever?
those are additional features to core webserver.
like apps in phone,
WordPress plugins,
Ex: status module, it collects& monitors the data to display end user.
if you don’t want use it disable otherwise it uses ram, low ram then slow server.
To view installed available modules
check installed modules apache
Enabled modules: ls /etc/apache2/mods-enabled/
Available modules: ls /etc/apache2/mods-available/
apache2ctl -M ubuntu / debian
To view enabled modules
apache2ctl -M
To install new module
to enable module
a2enmod modname
a2enmod rewrite
to disable module
a2dismod module name
A2dismod mod_deflate
to completely remove or uninstall module
apt-get remove php-mod
configuration of module
nano etc/apache2/mods-enabled/mid_rewite.conf
set memory limits etc.
Save.
Reload apache server.
apache core modules
Mpm_common
collection of directives for multi processing module mpm
core
Web server always available
event
threads only for active connection.
threads always runs by using memory. to handle connections quickly rather than spawning at the time of connection like mpm_event better to use php_fpm instead of php_mod
mpm_event
Mpm_worker: mult threaded process
Child process has multiple threads, each thread handle one connection
mpm_Prefork
non threaded preforking webserver. One connection one process, one process = dedicated memory allocation just like phomemory limit untill child process dies, better to use with mod_php
<IfModule mpm_event_module> StartServers 3 MinSpareThreads 25 MaxSpareThreads 75 ThreadLimit 64 ThreadsPerChild 25 MaxRequestWorkers 30 MaxConnectionsPerChild 1000</IfModule>
same like php-fpm pool manger in nginx.
run
apache2-v
To view apache version along with core module
/etc/apache2/mods-available/<mpm>.load
switch mpm_event,mpm_worker_mpm_prefork
to better understand apache architecture, read apache vs nginx architecture
nginx single threaded non blocking (so les memory)
nginx workers=equals to cpu core.
1 worker can handle 1024 connections.
2=2048 concurrent connections per second that not always means
2048 live visitors(more than this or below based configuration )
apache max client reached
MaxClients directive replaced with
MaxRequestWorkers
make sure increase maxclinent 500 to 2000(based on traffic in apache.conf
Most common used modules
rewrite
Gzip
httpheaders
ssl
1) Mod_security (set of basic security rules)
2) Mod_rewrite (must otherwise you get 404 errors except homepage)
3) Mod_deflate or Mod_Brotil (compression algorithms)
4) Mod_cache
5) Mod_proxy
Optional for proxy, useful when you use nginx as reverse proxy for apache
6) Mod_ssl,
enable this if you want to use HTTPS or SSL.
Mod_cache
caches dynamic web pages & stores as static pages for some time ex: 1 hour just like fastcgi cache
More module & more features
Modules that need to use
Mod-evasis
avoids bootforce attack