LAMP vs LEMP — Why This Series Uses Nginx

The difference between LAMP and LEMP stacks for WordPress, why Nginx is the better choice for a VPS, and an honest admission: most people pick Nginx because tutorials recommend it, and that's a fine reason.

Diagram comparing LAMP and LEMP stack components side by side

When people say “set up a WordPress VPS,” they usually mean one of two software stacks. The difference comes down to one component: the web server.


What LAMP and LEMP Are

LAMP:

  • Linux — operating system
  • Apache — web server
  • MySQL — database
  • PHP — scripting language

LEMP:

  • Linux — operating system
  • ENginx (pronounced “engine-x”) — web server
  • MariaDB or MySQL — database
  • PHP-FPM — PHP process manager

The databases are interchangeable in practice — MariaDB is a drop-in MySQL replacement and the default on Rocky Linux. The meaningful choice is between Apache and Nginx.


Apache vs Nginx — What Actually Differs

How They Handle Requests

Apache uses a process-based model: each incoming connection spawns a new thread or process. Under high concurrent traffic, this scales poorly because each process consumes RAM while waiting for PHP or the database to respond.

Nginx uses an event-driven model: a small number of worker processes handle many connections simultaneously using non-blocking I/O. Under the same load, Nginx typically uses significantly less memory.

On a $12-20/month VPS with 1-2GB RAM, this difference is real. Apache can exhaust available memory under moderate traffic; Nginx handles the same load while leaving RAM available for PHP-FPM, MariaDB, and Redis.

Diagram comparing Apache process-per-connection model vs Nginx event-driven model — showing fewer Nginx worker processes handling the same number of connections
Apache spawns a process per connection. Nginx handles many connections with few workers. The memory difference matters on a budget VPS.

FastCGI Cache — The Main Reason for Nginx

This is the feature that makes the most practical difference for WordPress.

Nginx includes built-in FastCGI caching: it can store the fully rendered HTML output of a WordPress page and serve it directly on subsequent requests — without running PHP, without querying the database. The page is served from memory in under a millisecond.

Without caching, every WordPress page request follows this path:

  1. Nginx receives the request
  2. Passes it to PHP-FPM
  3. PHP runs, queries MariaDB
  4. MariaDB returns results
  5. PHP generates HTML
  6. Nginx sends HTML to the visitor

With FastCGI cache on a cache hit:

  1. Nginx receives the request
  2. Serves cached HTML directly

Steps 2-5 are skipped entirely. The improvement on real traffic is measurable — time to first byte drops dramatically.

Apache can achieve similar results with plugins like WP Rocket’s page cache or server-side caching solutions, but Nginx’s implementation is native, requires no additional software, and operates at the server level rather than the application level.

PHP-FPM vs mod_php

Apache commonly uses mod_php — PHP runs as an Apache module, tightly coupled with the web server process. Each Apache process includes PHP, whether or not the current request needs it.

PHP-FPM is a separate process that handles PHP execution. Nginx communicates with it via a Unix socket. The advantages: PHP processes are independent of the web server, can be tuned separately, and support per-pool configuration (useful when running multiple WordPress sites with different PHP settings).


The Honest Take on Nginx Config

Nginx configuration is not beginner-friendly. The syntax is clean but unforgiving — a missing semicolon or a misconfigured location block fails silently or produces confusing 502 errors. Regex patterns for URL rewriting are particularly opaque.

When I started with Nginx, config errors were the source of most of my debugging time. Stack Overflow helped. Trial and error helped more. It was slow.

The situation is different now. You can paste a broken Nginx config into AI, describe what you want it to do, and get back a working version with an explanation. This has made Nginx’s learning curve meaningfully shallower for beginners.

This series provides the exact Nginx configs you need for each step. If something breaks, paste the error and the config into AI — you’ll get an answer faster than any forum.


Why Follow the Crowd Here

When I started with Nginx, I copied what tutorials recommended because I didn’t know enough to make an independent judgment. That turned out to be the right call — not because of the copying, but because Nginx actually is the better choice for a VPS running WordPress.

The reasoning:

  • Less memory usage on limited VPS RAM
  • FastCGI cache at the server level
  • PHP-FPM decoupling
  • Better handling of concurrent connections

You don’t need to understand all of this before installing it. The next article installs Nginx on Rocky Linux 9, and the configuration comes together piece by piece through Part 4 and Part 5.


What This Part Covers

Five articles building the LEMP stack from scratch:

  • 4.2 — Install Nginx on Rocky Linux 9
  • 4.3 — Install MariaDB and create the WordPress database
  • 4.4 — Install PHP-FPM with the right version and extensions
  • 4.5 — Configure the Nginx server block with FastCGI cache
  • 4.6 — Test the full stack before installing WordPress

By the end of Part 4, you have a working web server environment. Part 5 installs WordPress on top of it.

Frequently Asked Questions

Can WordPress run on Apache instead of Nginx?
Yes, WordPress runs on Apache perfectly well — it's what most shared hosting uses. The choice matters more on a VPS where you control the server. Nginx's event-driven architecture handles concurrent connections more efficiently on limited RAM, which matters on a $12-20/month VPS.
Is Nginx config really more complicated than Apache?
For basic WordPress setup, no — this series provides the exact config you need. For advanced cases like complex rewrite rules, regex patterns, or unusual setups, yes, Nginx config syntax is less forgiving. AI has made this significantly easier: paste an error, describe what you want, get a working config.
What is FastCGI cache and why does it matter?
FastCGI cache lets Nginx store fully rendered WordPress pages in memory and serve them directly without PHP or MySQL being involved. A cached page can be served in under a millisecond. Without it, every request hits PHP and the database. The performance difference on a real VPS is measurable.
What is PHP-FPM and why use it instead of mod_php?
PHP-FPM (FastCGI Process Manager) runs PHP as a separate process that Nginx communicates with via a socket. It's more efficient than mod_php (which ties PHP directly into Apache), allows per-site PHP configuration, and supports process pool tuning — important when running multiple WordPress sites.