Mastodon

LAMP vs LEMP: Choosing a Stack for WordPress on a VPS

  1. Home
  2. Blog
  3. LAMP vs LEMP: Choosing a Stack for WordPress on a...

LAMP and LEMP are the two standard ways to assemble a WordPress server: Linux, a web server, MySQL or MariaDB, and PHP. LAMP uses Apache as the web server. LEMP swaps in Nginx, pronounced "engine-x", which is where the E comes from. Both stacks run WordPress correctly and both are used at real scale in production, so this is not a question of one being broken and the other being fixed. It is a question of how each web server handles requests, and which behaviour fits better on a VPS where you are managing your own resources.

How Apache and Nginx Handle Requests Differently

Apache's traditional model spins up a process or thread per connection, and keeps that worker alive for the life of the request. This makes Apache flexible: per-directory configuration through .htaccess files lets you override behaviour without touching the main config, which is why so many WordPress plugins and older tutorials assume Apache is available. The cost is memory. Each worker carries its own overhead, and under heavy concurrent traffic that adds up fast, particularly on a VPS with 4GB or 8GB of RAM rather than a beefy dedicated box.

Nginx uses an event-driven, asynchronous model instead. A small number of worker processes handle thousands of connections each without spawning a new process per request, which keeps memory use flat as concurrent connections climb. The trade-off is configuration style: Nginx does not read .htaccess files at all, so every rewrite rule and per-directory override has to live in the main server config. That is a deliberate performance decision, not a missing feature. Reading .htaccess means scanning the filesystem on every single request looking for override files; skipping that lookup is part of why Nginx handles concurrency more efficiently.

Where LAMP Still Wins

Some WordPress plugins, particularly older security and redirect plugins, write their rules directly into .htaccess and assume Apache is reading them. On LEMP, those plugins either need a manual Nginx equivalent added to the server block or they silently do nothing, which catches people out during a migration. If you are running a site with a long plugin history and no appetite for auditing what each one expects from the web server, Apache's compatibility is worth something real. Apache's process-per-connection model is also, in practice, easier to reason about when something goes wrong; a runaway PHP process is isolated to its own worker rather than sharing a pool with everything else.

Where LEMP Wins

On a VPS where RAM is a fixed, purchased resource rather than something you can quietly scale up, Nginx's lower per-connection overhead translates directly into more headroom for the rest of the stack, PHP-FPM and MySQL or MariaDB included. This is the main reason LEMP has become the default choice for performance-focused WordPress hosting: it is not that Apache cannot serve WordPress fast, it is that Nginx serves more concurrent requests on the same RAM budget. Nginx also handles static assets, images, CSS, JavaScript, extremely efficiently, and pairs naturally with PHP-FPM for process management rather than relying on an embedded PHP module.

A full breakdown of the performance difference in practice, including how each handles a WooCommerce storefront under load, is covered in the site's dedicated comparison of Nginx and Apache for WordPress.

Which to Choose on a VPS

For a new WordPress deployment on a self-managed VPS, LEMP is the better default. The memory efficiency matters more on a VPS with a fixed RAM allocation than it does on managed hosting where the provider is absorbing that overhead for you, and the configuration-in-code approach that Nginx forces actually pays off long term: your entire server config lives in version-controllable files rather than being scattered across .htaccess files in every directory. The main case for choosing LAMP instead is migrating an existing site with a long plugin history that leans on Apache-specific behaviour, where the migration risk of auditing every plugin's .htaccess rules outweighs the performance gain.

If you are deploying fresh, the site's guide to deploying WordPress on a Linux VPS with Nginx and PHP-FPM walks through the full LEMP setup on Ubuntu 24.04 from a bare VPS to a running install.

Frequently Asked Questions

Can I switch from LAMP to LEMP later?

Yes, but it involves rewriting any .htaccess rules as Nginx server block directives and testing every plugin that touches URL rewriting, so it is a real migration rather than a quick swap. It is far less work to choose correctly at deployment than to convert an established site afterwards.

Does LEMP support WordPress permalinks?

Yes, with a try_files directive in the Nginx server block that routes unmatched requests through index.php, which is the Nginx equivalent of Apache's mod_rewrite handling pretty permalinks. It is a standard part of any WordPress-on-Nginx configuration and is included in the site's LEMP deployment guide.

Is Nginx harder to manage than Apache on a VPS?

It requires a different habit rather than more difficulty: every override goes into the server block config file instead of a .htaccess file next to the content it affects. Once that habit is established, most administrators find a single well-organised config file easier to audit than rules scattered across a directory tree.

Related Articles

WordPress

Why Is My WordPress Admin So Slow? (And How to Fix It)

Struggling with a slow WordPress admin? This guide covers the 5 most common caus...

WordPress

WP Rocket vs W3 Total Cache vs LiteSpeed Cache vs WP Super Cache: Which is Best?

WP Rocket, W3 Total Cache, LiteSpeed Cache, and WP Super Cache compared. Which o...

WordPress

Nginx vs Apache for WordPress: Which Should You Choose?

Nginx and Apache handle requests in fundamentally different ways, and that diffe...