In short
With PHP-FPM the web server is rarely the bottleneck; PHP and the database are. Choose Apache if the application relies on .htaccess or your team knows Apache. Choose nginx if you configure centrally, serve many static files or already use nginx as a proxy.
| Criterion | nginx | Apache |
|---|---|---|
| Connection to PHP | fastcgi_pass to the PHP-FPM socket or port | mod_proxy_fcgi with event MPM, or mod_php |
| .htaccess | Not supported, rules must go into the server config | Supported, applications ship their own rules |
| Config style | Central, compact, location blocks | Central plus distributed via .htaccess, many modules |
| Upload limit | client_max_body_size | LimitRequestBody |
| Timeout to PHP | fastcgi_read_timeout | ProxyTimeout or Timeout |
| Static files | Very light on resources | Good, also efficient with event MPM |
| Vendor docs | Available for Nextcloud and many apps, but rules must match exactly | Often the application's reference setup |
| Config test | nginx -t | apachectl configtest |
Pick nginx if …
- nginx already runs as reverse proxy or TLS terminator for other services.
- you want every rule central and version-controlled in the server config.
- you serve many static files or handle many concurrent connections.
- users or plugins must not change web server rules via .htaccess.
Pick Apache if …
- the application ships and updates
.htaccessrules, such as WordPress plugins or Nextcloud. - you run shared-hosting style setups where customers need their own rules.
- the team knows Apache and has no time for a migration.
- you want modules like
mod_auth_mellonormod_auth_openidc.
Pitfalls from operations
- 502 Bad Gateway after updates: the PHP-FPM socket moved or has wrong permissions. Compare the socket path in the web server and the pool config.
- Uploads fail although PHP was adjusted: the limit in the web server or the proxy in front is still small.
- 504 Gateway Timeout on long tasks: the web server timeout is shorter than
max_execution_timeorrequest_terminate_timeoutin PHP-FPM. - After moving from Apache to nginx, .htaccess protection rules are gone. Check that directories like
data/orconfig/are not reachable over HTTP.
FAQ
Is nginx faster than Apache?
For static files and many open connections nginx is usually lighter. For PHP applications behind PHP-FPM, response time is almost always decided by PHP, caching and the database, not by the web server.
Can I combine both?
Yes, a common setup is nginx in front as a TLS reverse proxy with Apache behind it. It works, but you get two sets of timeouts, upload limits and logs to check when something fails.