VPS & Servers

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.

Nginx, Apache and LiteSpeed web servers compared side by side

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 .htaccess per 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

NginxApacheLiteSpeed
How it handles visitorsEvent-driven: a few workers handle thousands of connectionsProcess or thread per connection (the event MPM narrows the gap)Event-driven, like Nginx
.htaccessNot supported: rules go in the server configFully supportedSupported (the free OpenLiteSpeed reads only the rewrite rules)
PHPThrough PHP-FPMPHP-FPM or the older mod_phpIts own fast LSAPI
Built-in page cacheFastCGI cache (manual setup)mod_cache (rarely used)LSCache, with ready plugins for WordPress and others
Reverse proxyExcellent, the most common choiceGood (mod_proxy)Good
License and priceFree (open source); paid NGINX PlusFree (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 .htaccess rules (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

ServerWhat it is for
TomcatAn application server for Java web apps (servlets, JSP). It is not a general web server; it usually sits behind Nginx or Apache.
TraefikA reverse proxy built for Docker and Kubernetes: it finds containers by itself and gets HTTPS certificates automatically
CaddyA 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 .htaccess or 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>
HeaderWhat it shows
ServerThe web server's name, unless the owner hid it
cf-rayCloudflare answered; the real server is behind it and may be hidden
x-litespeed-cacheLiteSpeed Cache served the page (hit) or built it (miss)
x-powered-byThe 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.

Where to go next

Questions people ask

Which is better, Nginx or Apache?
Nginx for a VPS you manage, high traffic, static files and reverse proxying. Apache when you need .htaccess per folder or many older PHP apps. For PHP pages the speed difference is small with PHP-FPM; caching matters more.
Is Nginx from Apache?
No. Apache HTTP Server is from the Apache Software Foundation (1995). Nginx was written by Igor Sysoev, released in 2004, and is now owned by F5. They are separate projects.
Is there something better than Nginx?
For some jobs: Caddy for automatic HTTPS with little setup, Traefik for Docker and Kubernetes, LiteSpeed for PHP and WordPress hosting, and HAProxy for load balancing. As a general web server, Nginx remains the safe default.
Does Netflix use Nginx?
Yes. Netflix's Open Connect content delivery network streams video from servers running FreeBSD and Nginx.
Is LiteSpeed faster than Nginx?
For PHP and WordPress with its LSCache page cache, LiteSpeed is often faster with less tuning. For static files and reverse proxying, the two are close. Benchmarks vary with configuration.
Which web server is best for WordPress?
LiteSpeed with the LiteSpeed Cache plugin is the easiest fast setup and reads WordPress's .htaccess. Nginx with PHP-FPM and FastCGI cache is just as fast on a VPS but needs rules in its config. Apache works with every plugin.
Does Nginx support .htaccess?
No. Nginx has no per-folder configuration files, so .htaccess rules must be rewritten into the server config, usually with try_files and location blocks.
What is the difference between Nginx and Tomcat?
Nginx is a web server and reverse proxy. Tomcat is an application server that runs Java web apps. They are often used together, with Nginx in front of Tomcat.
Nginx or Traefik as a reverse proxy?
Traefik for Docker and Kubernetes, because it discovers containers and gets HTTPS certificates by itself. Nginx for classic servers and when you need fine control, caching and maximum speed.
How can I see which web server a website uses?
Look at the response headers in your browser's developer tools (Network tab), or use a small script that reads the Server, cf-ray, x-litespeed-cache and x-powered-by headers. Some sites hide their server name.

Written by Habib Baloch

I build Android apps, websites and Ubuntu servers, and write down exactly how I did it.

Ask me about this guide →