Apache HTTP Server
Apache HTTP Server (commonly called Apache) is one of the oldest and most widely used web servers. First released in 1995, it powers a significant portion of websites worldwide and is known for its flexibility and extensive module system.
Key Features
- Module system: Extend functionality with 500+ available modules
- Virtual hosts: Serve multiple domains from one server
- .htaccess: Per-directory configuration without server restart
- URL rewriting: Powerful mod_rewrite for URL manipulation
- Cross-platform: Runs on Linux, Windows, macOS
Common Modules
| Module | Purpose |
|---|---|
| mod_rewrite | URL rewriting and redirection |
| mod_ssl | HTTPS/TLS support |
| mod_proxy | Reverse proxy and load balancing |
| mod_php | PHP processing |
| mod_security | Web application firewall |
| mod_deflate | Compression |
| mod_headers | Custom HTTP headers |
Configuration Example
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/example
<Directory /var/www/example>
AllowOverride All
Require all granted
</Directory>
# Redirect to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
Apache vs Nginx
| Aspect | Apache | Nginx |
|---|---|---|
| Architecture | Process/thread per connection | Event-driven, async |
| Memory usage | Higher | Lower |
| Static files | Good | Excellent |
| Dynamic content | Native (mod_php) | Proxy to PHP-FPM |
| Configuration | .htaccess flexibility | Centralized only |
| Market share | Declining | Growing |
What We Like
- Flexibility: .htaccess allows per-directory configuration
- PHP integration: Native mod_php is simple to set up
- Documentation: Decades of community knowledge
- Stability: Battle-tested and reliable
What We Don't Like
- Performance: More resource-intensive than Nginx
- Complexity: Configuration can become unwieldy
- Modern workloads: Not optimised for WebSockets, high concurrency
- Declining relevance: Nginx and cloud services taking over
When to Use Apache
- Legacy applications expecting Apache features
- WordPress and PHP applications needing .htaccess
- Shared hosting environments
- When mod_rewrite rules are already written
Modern Alternatives
For new projects, consider:
- Nginx: Better performance for static and reverse proxy
- CloudFront + S3: Static hosting
- API Gateway: Serverless APIs
- Platform-native: Let Next.js or Nuxt handle serving