With each Apache process consuming ~70MB RSS memory, we need to strategically disable non-essential modules while maintaining full functionality for Magento 2 and WordPress. Let's examine the loaded modules in your configuration.
# Absolutely required modules (static or critical):
core_module
mpm_prefork_module
http_module
so_module
fcgid_module
ssl_module (if using HTTPS)
rewrite_module (essential for both CMS platforms)
These modules consume memory but provide no value for typical Magento/WordPress deployments:
# Authentication modules (unless you need specific auth methods)
auth_digest_module
authn_alias_module
authn_anon_module
authn_dbm_module
authz_dbm_module
authnz_ldap_module
ldap_module
# Legacy/unused protocols
dav_module
dav_fs_module
dav_svn_module
authz_svn_module
proxy_ftp_module
# Development/diagnostics
info_module
status_module
autoindex_module
userdir_module
These might be needed depending on your specific setup:
# Disable if not using proxy functionality
proxy_module
proxy_balancer_module
proxy_http_module
proxy_ajp_module
proxy_connect_module
# Disable if not using caching
cache_module
disk_cache_module
# Disable if not using Perl
perl_module
sed_module
Here's how to disable modules in your httpd.conf:
# Example disable directives
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_anon_module modules/mod_authn_anon.so
# Comment out or remove the above lines to disable
# Alternative method (recommended for most cases):
sed -i '/mod_auth_digest.so/s/^/#/' /etc/httpd/conf.modules.d/00-base.conf
After making changes:
apachectl configtest
systemctl restart httpd
# Check memory usage:
ps aux | grep 'httpd' | awk '{print $5/1024 " MB"}' | sort -n
Disabling the suggested modules typically reduces memory usage by 15-25MB per process. For a server with 100 Apache children, this could free up 1.5-2.5GB of RAM.
Watch for these metrics post-change:
1. PHP-FPM/FCGID error rates
2. Magento admin panel functionality
3. WordPress permalinks
4. Any custom .htaccess rules
The modules marked as (static)
are compiled into Apache and cannot be disabled without recompiling. We'll focus on the (shared)
modules that can be safely removed from your httpd.conf
or via a2dismod
on Debian-based systems.
These modules are critical for your stack:
rewrite_module # Required for WordPress/Magento URL rewriting
deflate_module # Compression
ssl_module # HTTPS support
headers_module # Security headers
expires_module # Browser caching
mime_module # File type handling
setenvif_module # Environment variables
alias_module # URL aliasing
fcgid_module # PHP-FPM handler
Here's the low-risk removal list with explanations:
# Authentication modules (unless using HTTP auth)
auth_basic_module
auth_digest_module
authn_* # All authn_* modules
authz_* # All authz_* except authz_host_module
# Unused protocol modules
dav_module # WebDAV
dav_fs_module
dav_svn_module # Subversion
authz_svn_module
# Legacy modules
userdir_module # User home directories
speling_module # URL spelling correction
info_module # Server info (security risk)
status_module # Server status (security risk)
# Unused proxy modules
proxy_*
cache_module
disk_cache_module
# Others
perl_module # Unless using Perl scripts
sed_module # Stream editing
usertrack_module # Cookie tracking
mime_magic_module # Replaced by mime_module
On Ubuntu/Debian systems, disable modules with:
sudo a2dismod auth_basic auth_digest dav
sudo systemctl restart apache2
For direct httpd.conf
editing:
# Comment out unnecessary LoadModule lines
#LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule dav_module modules/mod_dav.so
Typical memory reduction per process:
Modules Disabled | Memory Saved |
---|---|
Basic auth modules | 3-5MB |
DAV/SVN modules | 4-6MB |
Proxy modules | 5-7MB |
Total potential | 12-18MB |
After changes, verify with:
apachectl -t # Check config syntax
apachectl -M # List loaded modules
ps aux | grep httpd # Check memory usage
If you need certain features temporarily, consider conditional loading:
<IfModule mod_headers.c>
Header set X-Content-Type-Options "nosniff"
</IfModule>