Apache HTTP Server

Work with Apache httpd, still common in PHP hosting, legacy stacks and enterprise environments.

Intermediate · about 3 hours · difficulty 2/5

Learn first: Reverse Proxies and Load Balancers

Apache HTTP Server (httpd) was the web's dominant server for decades and still runs a large share of sites, especially shared PHP hosting, WordPress installs and older enterprise systems. You are likely to meet it when maintaining existing infrastructure.

Key ideas

  • Virtual hosts (<VirtualHost *:443>) serve multiple sites from one server.
  • Modules add features: mod_ssl for TLS, mod_rewrite for URL rewriting, mod_proxy and mod_proxy_http for reverse proxying, mod_headers for response headers.
  • MPMs (multi-processing modules) decide the concurrency model: prefork (process per connection, needed by old mod_php setups), worker and event (threaded, much more efficient). Use event with PHP-FPM for modern deployments.
  • .htaccess files allow per-directory configuration without touching the main config. Convenient on shared hosting, but slower, since Apache checks for them on every request.

As a reverse proxy

ProxyPass "/api" "http://127.0.0.1:3000/" and ProxyPassReverse forward traffic to an app server, and mod_proxy_balancer spreads load across several.

Operating it

Test with apachectl configtest before reloading, and read error_log first when something fails. Rewrite rules are powerful but hard to debug; keep them few and commented.

When to choose it today

For new projects Nginx or Caddy are usually simpler and more efficient. Apache remains a reasonable choice when you need .htaccess compatibility, specific modules, or when your organization already standardizes on it.

You are ready to move on when you can set up a virtual host with TLS that proxies to your app and explain why the event MPM beats prefork for concurrency.

Key concepts

  • Virtual hosts
  • Core modules: ssl, rewrite, proxy
  • MPMs: prefork, worker, event
  • .htaccess files
  • PHP-FPM integration
  • mod_proxy_balancer

Other options for this step

  • Nginx: Configure the most widely deployed web server and reverse proxy for your backend.
  • Caddy: Use Caddy for a reverse proxy with automatic HTTPS and a tiny, readable configuration.

Mini project

Configure Apache with a TLS virtual host that serves static files and proxies /api to your backend, then move a rewrite rule from .htaccess into the main config.

Check yourself

Why do .htaccess files slow Apache down, and when are they still worth using?

Free resources