DevOps comparison · Stack

Nginx, Apache or LiteSpeed: which web server should you use?

Nginx, Apache and LiteSpeed serve the same websites, but they differ in how they handle connections, whether they read .htaccess files and how they are licensed. This page compares the three on WordPress, caching, HTTP/3, cPanel compatibility and the reverse proxy role.

Updated on

Short answer

  1. Use Nginx as a reverse proxy for Node.js, Python or Go applications, Apache when you need full .htaccess compatibility, and LiteSpeed for WordPress with server-level caching.
  2. Nginx handles connections with an event-driven architecture and never reads .htaccess files.
  3. Apache looks for .htaccess files in every directory on every request, which costs performance even when the files do not exist.
  4. LiteSpeed Enterprise reads .htaccess without a restart and has a cPanel plugin, whereas OpenLiteSpeed is free but needs a restart to pick up a new .htaccess.
  5. All three run on a VPS or a dedicated server, where 4hosting configures the stack from the DevOps hours included in your plan.
HTTP/3 in Nginx
since 1.25.0, experimental module
Recommended Apache MPM
event, with a dedicated listener thread
OpenLiteSpeed
open source, free
LiteSpeed Enterprise
commercial, with a free tier

Side-by-side comparison

Nginx vs Apache vs LiteSpeed by technical criteria
CriterionNginxApacheLiteSpeed
Processing modelEvent-driven, asynchronousMPM prefork, worker or eventEvent-driven
.htaccess filesNot readYes, per directoryFull in Enterprise, rewrite rules only in OpenLiteSpeed
.htaccess reloadNot applicableOn every requestAutomatic in Enterprise, after a restart in OpenLiteSpeed
WordPressRewrite rules move into the server configurationWorks directly with .htaccessWorks directly, plus LSCache
Page cacheFastCGI cache, configured by handmod_cache, configured by handLSCache, with CMS plugins
HTTP/3 and QUICSince 1.25.0, experimentalNo native support in 2.4Yes, in both editions
cPanelOptional, as a proxy in front of ApacheThe classic web serverPlugin in Enterprise only
LicenceOpen source, BSDOpen source, Apache 2.0OpenLiteSpeed GPLv3, Enterprise commercial
Reverse proxyStrong point, widely usedPossible, via mod_proxyPossible, via external applications

When to choose each option

Choose Nginx if

  • You run Node.js, Python or Go applications that need a reverse proxy in front.
  • You serve many static files and many simultaneous keep-alive connections.
  • You control the server configuration and do not depend on .htaccess.
  • You want TLS termination and load balancing in front of several containers.

Choose Apache if

  • Your application ships its rules in .htaccess and has to work without changes.
  • Several users without root configure their own directories.
  • You rely on specific Apache modules that you do not want to rewrite.
  • You have an older PHP site that has been tested on Apache for years.

Choose LiteSpeed if

  • You host several WordPress sites and want page caching at server level.
  • You want .htaccess compatibility without the cost of checking it on every request.
  • You need HTTP/3 enabled without experimental modules.
  • You accept either the commercial Enterprise licence or the restart that OpenLiteSpeed requires.

Process model: events versus threads

Nginx manages connections through an event loop with a small number of worker processes. Apache offers three processing modules. Prefork uses one process per connection and no threads. Worker uses threads but keeps a thread busy for the whole keep-alive period. Event adds a listener thread that takes over idle connections and frees the worker threads at once. LiteSpeed is event-driven as well. On a modern Apache, event is the right module, and prefork remains only for modules that do not support threads.

.htaccess, WordPress and caching

The Apache documentation advises putting rules in the main configuration whenever you can edit it. The reason is that with .htaccess enabled, the server looks for the file in every parent directory on every request. Nginx never reads .htaccess, so WordPress rewrite rules have to be written into the server configuration. LiteSpeed Enterprise reads .htaccess and notices changes by itself. For WordPress, the LiteSpeed Cache plugin uses server-level caching only on LiteSpeed or OpenLiteSpeed.

  • Apache: .htaccess read on every request
  • Nginx: rules live only in the configuration
  • LiteSpeed: .htaccess plus LSCache

HTTP/3, licences and reverse proxying

Nginx has an HTTP/3 module since version 1.25.0, marked experimental and not compiled in by default. Apache httpd 2.4 has no native HTTP/3 support, so a proxy is often placed in front of it. Both LiteSpeed editions support HTTP/3 and QUIC. On licences, Nginx and Apache are open source. OpenLiteSpeed is free and open source, while LiteSpeed Enterprise is commercial, with a free tier. A common VPS layout is Nginx as the reverse proxy in front of an application, or in front of Apache.

Examples from Romania

Iasi: an agency with a shared WordPress server

A web agency in Iasi hosts around thirty client WordPress sites on one dedicated server. Plugins write rules into .htaccess, and clients cannot touch the server configuration. LiteSpeed Enterprise keeps those files working and adds LSCache, so nobody rewrites the rules by hand for each site.

Cluj-Napoca: a Node.js API behind a proxy

A software team in Cluj-Napoca runs a Node.js API, a Next.js frontend and PostgreSQL in containers on one VPS. Nginx sits in front, terminates TLS, serves static files and spreads requests across the containers. Nothing here needs .htaccess, so Apache's main advantage never comes into play.

Bucharest: a legacy PHP application

A Bucharest company keeps an older PHP application that has run on Apache for years and ships its rules in .htaccess. The team moves it to a VPS unchanged, keeps Apache, and puts Nginx in front to terminate TLS and serve static files.

Common mistakes

  • Moving a WordPress site to Nginx and forgetting to rewrite the rules from .htaccess.
  • Leaving Apache on the prefork MPM without a reason tied to incompatible modules.
  • Enabling HTTP/3 in Nginx without opening UDP port 443 in the firewall.
  • Installing the LiteSpeed Cache plugin on Nginx and expecting server-level caching.
  • Editing .htaccess on OpenLiteSpeed and forgetting that new rules need a restart.

How 4hosting helps

  • Root access on VPS and dedicated servers, so you can run Nginx, Apache or LiteSpeed.
  • Included DevOps hours, between 1 and 8 a month on a VPS depending on the plan, can cover web server and reverse proxy configuration.
  • Dedicated servers include 5 to 10 DevOps hours a month depending on the plan, usable for moving .htaccess rules and tuning the cache.
  • L3/L4 DDoS protection and a symmetric 10 Gbps network sit in front of your web server.
  • Free migration of your sites from your current provider onto servers in our Frankfurt datacentre.

Related questions

  • Does WordPress work on Nginx?

    Yes. WordPress runs on Nginx with PHP-FPM, but Nginx does not read .htaccess. Permalink rules and anything your plugins write must be moved into the server configuration, and plugins that edit .htaccess will have no effect on Nginx.

  • Is OpenLiteSpeed as good as LiteSpeed Enterprise?

    For a single site with root access, OpenLiteSpeed is often enough, and it is free. The gap shows with .htaccess: Enterprise reads it automatically, while OpenLiteSpeed supports only rewrite rules and needs a restart. The cPanel plugin exists only in Enterprise.

  • Can I put Nginx in front of Apache?

    Yes. Nginx as a reverse proxy serves static files and terminates TLS, while Apache runs PHP and reads .htaccess. This combination keeps older applications compatible and reduces the number of connections Apache has to hold open.

Sources

Ask for an infrastructure recommendation

Nginx for reverse proxying and modern applications, Apache for .htaccess compatibility, LiteSpeed for WordPress with server-level page caching.