Nginx vs Apache vs LiteSpeed: Which Web Server Should You Use?
Nginx, Apache and LiteSpeed compared in plain words: how they work, performance, PHP and WordPress, .htaccess, reverse proxy, how they differ from Tomcat, Traefik and Caddy, which big sites use what, and a tested PHP page that shows which server any website runs.
Three web servers run most of the internet's websites. By W3Techs' count in May 2026, Nginx served about 33% of sites whose server is known, Apache about 24% and LiteSpeed about 15%, with Cloudflare's servers in front of another 28%. All three are fast and reliable. They differ in how they handle many visitors, how they run PHP, whether they read .htaccess, and how much work they are to set up.
This guide compares them in plain words, answers the questions people ask most, and gives you a small tested PHP page that shows which server any website uses.
The short answer: which is better, Nginx or Apache?
- Nginx for a VPS you manage yourself, for high traffic, for static files and as a reverse proxy in front of apps
- Apache when you need
.htaccessper folder, many old PHP scripts, or the simplest setup on shared hosting - LiteSpeed for WordPress and PHP hosting where you want speed and Apache compatibility; many cheap hosts that advertise speed use it
Nginx vs Apache vs LiteSpeed at a glance
| Nginx | Apache | LiteSpeed | |
|---|---|---|---|
| How it handles visitors | Event-driven: a few workers handle thousands of connections | Process or thread per connection (the event MPM narrows the gap) | Event-driven, like Nginx |
.htaccess | Not supported: rules go in the server config | Fully supported | Supported (the free OpenLiteSpeed reads only the rewrite rules) |
| PHP | Through PHP-FPM | PHP-FPM or the older mod_php | Its own fast LSAPI |
| Built-in page cache | FastCGI cache (manual setup) | mod_cache (rarely used) | LSCache, with ready plugins for WordPress and others |
| Reverse proxy | Excellent, the most common choice | Good (mod_proxy) | Good |
| License and price | Free (open source); paid NGINX Plus | Free (open source) | Paid Enterprise; free OpenLiteSpeed |
Nginx vs Apache performance
For static files (images, CSS, JavaScript) and many open connections, Nginx and LiteSpeed use less memory and stay steady under load, because they do not start a process for every visitor. For PHP pages, the difference is smaller than most benchmarks suggest: the time goes into PHP and the database, and Apache with PHP-FPM and the event MPM is far closer to Nginx than the old mod_php setups. The biggest speed jump for a PHP site usually comes from page caching, which is where LiteSpeed's LSCache shines.
Nginx vs Apache for PHP
Apache can run PHP inside itself (mod_php) or hand it to PHP-FPM; Nginx always hands it to PHP-FPM. The practical difference is configuration. Here is the same “send every address to index.php” rule, which most PHP scripts and WordPress need, on each server:
# Apache (and LiteSpeed): .htaccess in the site's folder
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
# Nginx: inside the site's server { } block (Ubuntu 24.04 with PHP 8.3)
root /var/www/site;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
# Caddy: the whole site, with automatic HTTPS
yourdomain.com {
root * /var/www/site
php_fastcgi unix//run/php/php8.3-fpm.sock
file_server
}
That is why many PHP scripts say “Apache or LiteSpeed with .htaccess”: the rules ship inside the script. On Nginx, someone has to put equivalent rules in the server config, including the ones that protect private folders.
Nginx vs Apache for WordPress
- LiteSpeed + LSCache is the easiest fast WordPress setup: it reads WordPress's
.htaccess, and the free LiteSpeed Cache plugin handles page caching. - Nginx + PHP-FPM with FastCGI cache is just as fast on a VPS, but plugins that write
.htaccessrules (security, redirects, caching) do nothing, so those rules have to go into the Nginx config. - Apache works with every plugin out of the box; add a caching plugin and it is fine for most sites.
Nginx vs Apache as a reverse proxy
A reverse proxy sits in front of an app (Node.js, Python, Java, n8n, a chat server) and handles HTTPS, compression and caching. Nginx is the most common choice for this job; Apache can do it with mod_proxy, and Caddy and Traefik make it even simpler. A popular mix is Nginx in front, passing PHP to Apache or apps to their own ports.
Nginx vs Apache vs Tomcat, Traefik and Caddy
| Server | What it is for |
|---|---|
| Tomcat | An application server for Java web apps (servlets, JSP). It is not a general web server; it usually sits behind Nginx or Apache. |
| Traefik | A reverse proxy built for Docker and Kubernetes: it finds containers by itself and gets HTTPS certificates automatically |
| Caddy | A modern web server and reverse proxy with automatic HTTPS and very short configs (see above). We use it in our n8n setup. |
Is there something better than Nginx?
Not better at everything, but better at some jobs: Caddy if you want HTTPS with no setup, Traefik for containers, LiteSpeed for PHP and WordPress hosting, and HAProxy for pure load balancing. For a general-purpose server, Nginx is still the safe default.
Is Nginx from Apache?
No. They are separate projects. Apache HTTP Server comes from the Apache Software Foundation and dates from 1995. Nginx was written by Igor Sysoev and first released in 2004 to handle many more connections at once; it is now owned by F5. LiteSpeed is a separate company's server, built to read Apache's configuration and .htaccess files.
Does Netflix use Nginx?
Yes. Netflix's own content delivery network, Open Connect, streams video from servers running FreeBSD and Nginx, which Netflix has described in its engineering talks. Many of the busiest sites run Nginx somewhere, often as the front door in front of other software.
What people on Reddit usually say
- Use Nginx on a new VPS unless you have a reason not to
- Keep Apache where
.htaccessor old apps make life easier; it is not “slow” with the event MPM and PHP-FPM - Pick LiteSpeed hosting for WordPress speed without tuning
- Try Caddy for small projects: automatic HTTPS saves the most time
Try it: which web server does a site use?
Upload this page to any PHP hosting and open which-server.php?url=example.com. It asks the site for its response headers only (no page body) and recognises Nginx, Apache, LiteSpeed (and its cache), Caddy and Cloudflare in front:
<?php
// which-server.php: which web server runs a website? Open which-server.php?url=example.com
// It reads the response headers, the way browsers' developer tools show them.
$url = trim($_GET['url'] ?? '');
if ($url !== '' && !preg_match('#^https?://#i', $url)) { $url = 'https://' . $url; }
$valid = filter_var($url, FILTER_VALIDATE_URL) && preg_match('#^https?://#i', $url);
$found = [];
if ($valid) {
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_NOBODY => true, // headers only
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 5,
CURLOPT_TIMEOUT => 15,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_USERAGENT => 'Mozilla/5.0 (which-server)',
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
]);
$raw = (string)curl_exec($ch);
curl_close($ch);
// Keep only the headers of the last response (after redirects)
$blocks = preg_split("/\r?\n\r?\n/", trim($raw));
$head = [];
foreach (preg_split("/\r?\n/", (string)end($blocks)) as $line) {
if (strpos($line, ':') !== false) {
[$k, $v] = array_map('trim', explode(':', $line, 2));
$head[strtolower($k)] = $v;
}
}
$server = $head['server'] ?? '';
if (isset($head['cf-ray'])) { $found[] = 'Cloudflare is in front of the site (cf-ray)'; }
if (stripos($server, 'litespeed') !== false) { $found[] = 'LiteSpeed or OpenLiteSpeed'; }
if (isset($head['x-litespeed-cache'])) { $found[] = 'LiteSpeed Cache answered this page (' . $head['x-litespeed-cache'] . ')'; }
if (stripos($server, 'nginx') !== false) { $found[] = 'Nginx'; }
if (stripos($server, 'apache') !== false) { $found[] = 'Apache'; }
if (stripos($server, 'caddy') !== false) { $found[] = 'Caddy'; }
if (isset($head['x-powered-by'])) { $found[] = 'Powered by: ' . $head['x-powered-by']; }
if (!$found) { $found[] = $server !== '' ? "Server header: $server" : 'The server hides its name'; }
}
?>
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Which web server?</title>
<style>body{font-family:system-ui,sans-serif;max-width:640px;margin:30px auto;padding:0 16px}input,button{padding:9px;font:inherit}li{margin:6px 0}</style>
</head>
<body>
<h1>Which web server?</h1>
<form><input name="url" placeholder="example.com" value="<?= htmlspecialchars($url) ?>" required> <button>Check</button></form>
<?php if ($url !== '' && !$valid): ?>
<p>That does not look like a web address.</p>
<?php elseif ($found): ?>
<ul><?php foreach ($found as $f): ?><li><?= htmlspecialchars($f) ?></li><?php endforeach; ?></ul>
<?php endif; ?>
</body>
</html>
| Header | What it shows |
|---|---|
Server | The web server's name, unless the owner hid it |
cf-ray | Cloudflare answered; the real server is behind it and may be hidden |
x-litespeed-cache | LiteSpeed Cache served the page (hit) or built it (miss) |
x-powered-by | The language or app behind the site, if the owner did not remove it |
Testing it on real sites showed LiteSpeed on our own blog, Cloudflare on cloudflare.com and Nginx on nginx.org.
What we learned running OpenLiteSpeed
Our own blog and shop run on OpenLiteSpeed. It is fast, but it reads only the rewrite rules from .htaccess: Header and FilesMatch lines are silently ignored, and a changed .htaccess may need a server restart. We protect private files with RewriteRule ... [F] lines and send security headers from PHP instead. The full story is in our free cPanel alternatives guide.
PHP scripts that run on all of them
Our PHP scripts ship with .htaccess rules written as rewrite rules, so they work as they are on Apache, LiteSpeed and OpenLiteSpeed. On Nginx, the clean addresses and protected folders need rules in the server config like the ones above; the game portal's README includes them.
- PHP blog script with admin panel: a fast blog with no WordPress, built for LiteSpeed-style hosting
- Digital products shop
- Online web tools website
- HTML5 game portal, with Nginx rules in its README