Apache · Configuration and operations
How do Apache modules work and how do you manage them?
Short answer
Modules extend Apache with directives, handlers and hooks, and are loaded with LoadModule or a2enmod, kept minimal and verified with apachectl -M. Some modules are compiled in statically.
A module can add configuration directives, hook into request phases, provide a handler or supply a protocol. Shared modules are .so files loaded at startup. Static modules are compiled into the binary and cannot be unloaded. mod_so enables shared module loading itself.
sudo a2enmod rewrite headers ssl
sudo apache2ctl -M | grep -E 'rewrite|headers|ssl'
sudo apache2ctl configtest
sudo systemctl reload apache2
httpd -M
httpd -lManaging the module set
- Enable only modules the site uses; every module adds code and configuration surface
- Check dependencies; some modules require a provider or companion module
- Removing a module can invalidate directives in existing configuration
- Module load order can matter for handlers and default providers
- Use IfModule guards for optional configuration, but do not hide a missing required module
- Static modules appear in httpd -l; shared modules appear in httpd -M
A minimal module set is easier to patch and audit. For a reverse proxy that only serves TLS and HTTP, load mod_ssl, mod_proxy, mod_proxy_http and the logging modules, and leave CGI, autoindex and unused auth providers out. Document why each additional module exists.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What is the difference between a static and a shared module?
- 2How do you list loaded modules?
- 3What happens if you disable a module that a directive depends on?
- 4How do you decide which modules to keep?
Say it in the interview
Modules add directives and request hooks. I enable shared modules with a2enmod or LoadModule, verify with apachectl -M, and run configtest before reloading. I keep the set minimal because every module is patched and audited surface. If a directive suddenly fails, I check whether its module or a dependency is actually loaded.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Apache mock interview and get scored feedback on depth, clarity and confidence.