Apache vs Nginx¶
Apache dominated for 20 years, Nginx is surpassing it in popularity.
Architecture¶
- Apache — process/thread-per-connection, .htaccess
- Nginx — event-driven, more efficient, centralized configuration
Performance¶
- Static files: Nginx 2-3x faster
- Concurrent connections: Nginx 10,000+
- RAM: Nginx ~2 MB/worker vs Apache ~10 MB/connection
When to Use Which¶
- Nginx — high traffic, reverse proxy, containers
- Apache — shared hosting, .htaccess, legacy
- Combination — Nginx in front of Apache
Configuration and Modules¶
Nginx uses declarative configuration with server and location blocks. Reverse proxy is set up simply using proxy_pass. Load balancing supports round-robin, least connections, and IP hash strategies. Nginx Plus (commercial version) adds health checks, session persistence, and a monitoring dashboard.
Apache uses .htaccess files for per-directory configuration, which is convenient for shared hosting but slower — Nginx has no equivalent and all settings are in the central configuration. For a modern stack (containers, microservices, reverse proxy), Nginx is the clear choice. Apache remains relevant for mod_php (shared hosting), mod_rewrite (complex URL rules), and environments where you need dynamic per-directory configuration without server restarts.
Nginx for New Projects¶
Apache for legacy and shared hosting.