Back to blog

Nginx vs Apache vs LiteSpeed: Which Web Server Fits Your Site?

IM Host EditorialOctober 25, 20266 min read
Nginx vs Apache vs LiteSpeed: Which Web Server Fits Your Site?

Apache, Nginx and LiteSpeed all serve websites reliably, and all three run large parts of the web. They differ in how they handle connections, how you configure them, and which kinds of sites they suit best. This comparison explains those differences in practical terms so you can pick one for your next server, or understand the one your hosting already uses.

The short version

  • Apache: the most flexible configuration, including per-directory .htaccess files. A natural fit for classic PHP apps and teams that already know it.

  • Nginx: event-driven, light on memory, and very good as a reverse proxy and static file server. A natural fit in front of Node.js, Python, Go or containers.

  • LiteSpeed: event-driven like Nginx, but it reads Apache configuration and .htaccess. It has a built-in page cache, LiteSpeed Cache, with plugins for WordPress and other platforms. A natural fit for PHP and WordPress hosting.

For most sites, the database and the application code are the bottleneck, not the web server. Pick based on how you work and what your app needs, then add caching. Caching usually makes a bigger difference than the choice of server.

How each one handles connections

Apache

Apache uses Multi-Processing Modules (MPMs). The older prefork MPM runs one process per connection, which uses a lot of memory under load. The event MPM, the default on current Debian and Ubuntu packages, uses threads and hands idle keep-alive connections to a listener thread, so it scales far better than older setups suggest. Check which MPM you have:

apache2ctl -V | grep -i mpm

If the answer is prefork, it is often because mod_php is installed, which only works with prefork. Moving PHP to PHP-FPM lets you switch to event.

Nginx

Nginx runs a small number of worker processes, usually one per CPU core. Each worker handles thousands of connections in an event loop. Memory use stays low and predictable as connections grow, which is why Nginx is a common choice for reverse proxies, load balancers and static file servers.

LiteSpeed

LiteSpeed Web Server is also event-driven. It runs PHP through its own interface, LSAPI, and includes a server-level page cache. It comes in two editions: LiteSpeed Web Server Enterprise, which is commercial and works as a drop-in replacement for Apache in control panels such as cPanel, and OpenLiteSpeed, which is open source and has its own configuration format.

Configuration: .htaccess or central config

This is the difference you notice day to day.

Apache reads .htaccess files from each directory on every request, when AllowOverride allows it. Users and apps can change rewrite rules, redirects and access rules without touching the main config or restarting anything. That is why shared hosting and many PHP apps rely on it. The cost is a few extra file lookups per request, and settings that are spread across many files.

Here is the core of the standard WordPress rewrite block for Apache:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Nginx has no .htaccess. All configuration lives in central files, and you apply changes with a reload. The same WordPress behavior in Nginx:

server {
    listen 80;
    server_name example.com;
    root /var/www/example;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }
}
sudo nginx -t && sudo systemctl reload nginx

Central config is easier to review and version, but a plugin that writes .htaccess rules will have no effect on Nginx. You have to translate those rules by hand.

LiteSpeed Enterprise reads Apache's configuration and .htaccess files directly, so existing Apache sites usually move over without rewriting rules. OpenLiteSpeed supports rewrite rules from .htaccess, but not every Apache directive, so test before you migrate.

PHP handling

  • Apache: mod_php (simple, but ties you to prefork) or PHP-FPM through mod_proxy_fcgi. PHP-FPM is the better default today.

  • Nginx: PHP-FPM only, over a Unix socket or TCP.

  • LiteSpeed: LSAPI with LSPHP, which LiteSpeed manages for you.

An Apache virtual host with PHP-FPM looks like this:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/example
    <Directory /var/www/example>
        AllowOverride All
        Require all granted
    </Directory>
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost"
    </FilesMatch>
</VirtualHost>

Caching

Full-page caching is where the biggest real-world speed gains come from for PHP sites.

  • LiteSpeed has LiteSpeed Cache built into the server. The LiteSpeed Cache plugin for WordPress controls it: it knows when a post changes and clears only the affected pages. The plugin's page cache needs a LiteSpeed server underneath.

  • Nginx has fastcgi_cache and proxy_cache. They are fast, but you write the rules for what to cache and when to bypass it, for example for logged-in users or the cart.

  • Apache has mod_cache, but most Apache sites cache at the application level with a plugin, or put a reverse proxy cache in front.

Side-by-side comparison

ApacheNginxLiteSpeed
Connection modelProcesses or threads (MPM)Event-drivenEvent-driven
.htaccessYesNoYes (Enterprise); rewrite rules (OpenLiteSpeed)
PHPmod_php or PHP-FPMPHP-FPMLSAPI
Built-in page cachemod_cachefastcgi_cache, proxy_cacheLiteSpeed Cache
Reverse proxyYes (mod_proxy)Yes, a core strengthYes
LicenseOpen sourceOpen source (commercial edition available)Commercial; OpenLiteSpeed is open source

Which one fits your site?

  • WordPress or other PHP sites on shared hosting or a control panel: LiteSpeed is a strong fit because it keeps .htaccess compatibility and adds a server-level page cache. Apache with PHP-FPM is also a solid, well-documented choice.

  • Node.js, Python, Go or Docker apps on a VPS: Nginx is the common choice as a reverse proxy in front of the app, handling TLS, compression and static files.

  • Legacy apps that depend on Apache modules or many .htaccess files: stay on Apache, use the event MPM and PHP-FPM, and you will get most of the performance benefit without rewriting anything.

  • A mix: some setups put Nginx in front of Apache, with Nginx serving static files and Apache handling PHP and .htaccess. It works, but it is two servers to maintain. Consider it only if you need both sets of features.

Not sure what a site runs on? Check the response header. Many servers hide or change it, so treat the result as a hint:

curl -sI https://example.com | grep -i '^server'

Switching servers: what to check

  1. List every rewrite rule and redirect, including those in .htaccess files deep in the directory tree.

  2. Check which Apache modules the site uses (apache2ctl -M) and find equivalents.

  3. Move the site to a staging copy first and test logins, forms, uploads and checkout.

  4. Lower your DNS TTL a day before, so you can switch back quickly if needed.

Run it on IM HOST

If you want the web server managed for you, IM HOST Shared Hosting and WordPress Hosting include LiteSpeed Cache, NVMe storage, free SSL and free daily backups for the whole subscription. If you want to choose and tune Apache, Nginx or OpenLiteSpeed yourself, a Linux VPS gives you full root access on KVM from $5/month. Either way, support engineers are available 24/7, and we move existing sites for free without downtime.

More from our blog

Discover more practical guides and product insights from the IM Host team.

View all articles