Deploy Nginx, MySQL & PHP in Minutes: The Ultimate LNMP One-Click VPS Guide

📢 Limited Time Offer | Hostinger Official Promo: Web Hosting up to 80% Off + Free Domain Claim Now →

💡 Summary

  • LNMP stands for Linux + Nginx + MySQL/MariaDB + PHP.
  • It is one of the most widely‑used server stacks for deploying WordPress and other PHP‑based websites on VPS.
  • This tutorial clarifies what LNMP is, how it differs from LAMP, and its relationship with aaPanel.
  • It then covers the practical installation workflow for the LNMP one‑click script, post‑installation validation, security configuration, and troubleshooting for typical errors.
💡

Most people first encounter LNMP while searching for how to install WordPress on a VPS. It's not a single piece of software — it's an acronym for four components working together. Getting that straight makes everything else easier to follow.


What LNMP Actually Is

Letter Software Role
L Linux Operating system
N Nginx Web server, handles HTTP requests
M MySQL / MariaDB Database, stores site data
P PHP Runtime environment, executes dynamic page logic

When a visitor loads a WordPress page, the request flows through the stack like this:

Browser
    ↓
  Nginx (handles request, forwards dynamic content)
    ↓
 PHP-FPM (executes WordPress PHP code)
    ↓
MySQL/MariaDB (reads and writes data)
    ↓
  Returns page to browser

Nginx receives the request. Static files — images, CSS, JavaScript — get served directly. Dynamic requests get handed off to PHP-FPM, which executes the WordPress code, queries the database, and assembles the HTML response. All four components are required.


LNMP vs LAMP

LAMP stands for Linux + Apache + MySQL + PHP. The only difference from LNMP is the web server: Apache instead of Nginx. Both stacks run WordPress without issue.

Nginx handles high-concurrency static file serving and reverse proxying more efficiently, and typically uses less memory — which matters on a VPS with limited resources. Apache has more complete .htaccess support, which some older PHP applications and certain WordPress plugins depend on. For those cases, LAMP is less friction.

For most VPS hosting scenarios, LNMP is the more common choice, which is why there's more documentation and more tutorials written around it.


LNMP One-Click Installer vs aaPanel: What's the Difference

This distinction causes confusion more often than it should.

Installing LNMP manually means separately installing Nginx, MySQL, and PHP-FPM, then configuring each one, managing permissions, and setting up directory structures. For anyone not fluent in Linux, that's a lot of surface area for things to go wrong. LNMP one-click installers handle all of that through a single script.

But LNMP one-click installer and aaPanel are not the same thing. They solve problems at different layers:

  • LNMP one-click installer: sets up the server environment. After it runs, you're still working in the command line.
  • aaPanel: provides a graphical web interface for managing the server. It also installs Nginx, MySQL, and PHP on your behalf — but adds a browser-based control panel on top.

If you prefer the command line, want a lightweight setup, and don't want an additional process running on the server, the one-click installer is the cleaner choice. If you'd rather manage everything through a GUI, aaPanel gets you there faster. Both paths lead to the same functional end state.


Before You Install

VPS memory guidance:

Use Case Minimum RAM Recommended RAM
Testing / learning 1 GB 1 GB
WordPress blog 1 GB 2 GB
WooCommerce store 2 GB 4 GB

Ubuntu 22.04 LTS, Ubuntu 24.04 LTS, and Debian 12 are the most stable targets for LNMP one-click installers. Don't install on a system that already has Apache or another web server running — port conflicts will follow.

Connect to the server:

ssh root@your-server-ip

Update the system before anything else:

# Ubuntu / Debian
apt update && apt upgrade -y

Installing the LNMP One-Click Package

The official LNMP one-click installer lives at lnmp.org. Commands and version numbers update periodically — verify the current command on the official site before running. The following is current as of writing:

wget https://soft.vpser.net/lnmp/lnmp2.0.tar.gz \
  -cO lnmp2.0.tar.gz
tar -zxvf lnmp2.0.tar.gz
cd lnmp2.0
./install.sh lnmp

The script launches an interactive selection process. Here's what each prompt is asking:

Nginx version: Choose the current stable release. No need to run a development build on a production server.

MySQL / MariaDB version: Both MySQL 8.0 and MariaDB 10.x work well with WordPress. If you're unsure, MySQL 8.0 is a safe default.

PHP version: Don't reflexively pick the newest version. The right choice depends on the compatibility requirements of your theme and plugins. PHP 8.2 has solid WordPress support and is a stable choice currently. If you plan to use older plugins, check their minimum PHP version requirements first.

Once selections are made, the installer compiles components from source. This takes longer than most package installs — plan for 10 to 40 minutes depending on your VPS specs. Long stretches without terminal output are normal. Don't interrupt the process.


Verifying the Installation

# Check versions
nginx -v
php -v
mysql --version

# Check service status
systemctl status nginx
systemctl status mysql

Open your server's IP address in a browser. If you see the Nginx welcome page, the web server is running correctly.

If port 80 is unreachable, check the firewall:

# Ubuntu / Debian (UFW)
ufw allow 80
ufw allow 443
ufw allow 22
ufw enable

Also check the security group rules in your cloud provider's control panel — both places need to allow the ports.


Installing WordPress

LNMP sets up the runtime environment. WordPress still needs to be installed separately.

Create the site directory, set up an Nginx server block (exact config file paths vary by LNMP version — reference the official documentation), then download WordPress:

cd /home/wwwroot/example.com
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz --strip-components=1
rm latest.tar.gz

# Set correct ownership and permissions
chown -R www:www /home/wwwroot/example.com
chmod -R 755 /home/wwwroot/example.com

Create the database:

mysql -u root -p
CREATE DATABASE wordpress_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your-strong-password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Then open your domain in a browser and follow the WordPress installation wizard to enter the database credentials and complete setup.


Security Configuration (Don't Skip This)

Going live on a fresh LNMP install without hardening it is a common mistake. At minimum, handle the following:

SSH key authentication

# Generate an SSH key on your local machine
ssh-keygen -t ed25519 -C "your-email"

# Upload the public key to the server
ssh-copy-id root@your-server-ip

After confirming key-based login works, edit /etc/ssh/sshd_config and disable password authentication:

PasswordAuthentication no
PubkeyAuthentication yes

Test key login before restarting SSH. Getting locked out of your own server because you disabled passwords before confirming the key works is a painful way to learn this lesson.

Keep MySQL off the public internet

MySQL listens on port 3306 by default. There's no reason for that port to be reachable from outside. Confirm the firewall isn't allowing 3306, and that MySQL is configured for local connections only.

Firewall: open only what's necessary

ufw allow 22
ufw allow 80
ufw allow 443
ufw enable

If you've changed the SSH port, substitute accordingly.


Common Issues and Fixes

502 Bad Gateway

Most often PHP-FPM isn't running, or the PHP socket path in the Nginx config doesn't match.

# Check PHP-FPM status (service name varies by PHP version)
systemctl status php8.2-fpm

# Restart PHP-FPM
systemctl restart php8.2-fpm

WordPress pages returning 404

Usually missing WordPress rewrite rules in the Nginx server block. Confirm the following is present:

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

Reload Nginx after making config changes:

nginx -s reload

PHP files being downloaded instead of executed

PHP-FPM isn't correctly wired to Nginx. The server block is missing the PHP pass-through configuration that tells Nginx to forward .php files to the PHP processor.

MySQL connection failure

systemctl status mysql

If the service is running, cross-check the database name, username, and password in wp-config.php against what was set during database creation. The host should be localhost.

SSL certificate application fails

Confirm DNS is resolving to the correct server IP and that port 80 is publicly reachable. Then use certbot:

apt install certbot python3-certbot-nginx -y
certbot --nginx -d example.com -d www.example.com

If Cloudflare proxy is active, switch it to DNS only before applying for the certificate. Re-enable the proxy after the certificate is successfully issued.


LNMP One-Click Installer vs aaPanel

Attribute LNMP One-Click aaPanel
Graphical interface
Resource usage Low Slightly higher
Multi-site management Command line GUI, one-click
SSL configuration CLI / certbot GUI, one-click apply
Database management MySQL CLI phpMyAdmin
Learning curve Requires Linux familiarity Lower
Best for Developers, Linux users Newcomers to self-hosted sites

Choose LNMP if you're comfortable in the command line, want a lean environment, and prefer not to run an additional panel process on the server. Choose aaPanel if you prefer a graphical interface, need to manage multiple sites, or have limited Linux experience. Both get WordPress running — the difference is purely in how you interact with the server day to day.

🚀

Ready for Cloudways? Now is the perfect time

Use our exclusive link for the best price — and help support our content.

← Previous
VPS Mart vs InterServer Comparison 2026: Pricing, Performance & Windows VPS
Next →
Hostinger vs SiteGround in 2026: Don’t Overpay! Which Host Should You Actually Choose?

🏷️ Related Keywords

💬 Comments

150 characters left

No comments yet. Be the first!

← Back to Articles

VPS Rankings specializes in VPS selection, featuring provider reviews, rankings, practical tutorials, performance benchmarks and exclusive deals. Everything you need for research, comparison and purchase is available in one place.We cover budget web hosting and overseas cloud servers, enabling straightforward comparisons of specs, routing and pricing across providers. We also track CN2 GIA, low-latency Asian routes and other optimized solutions for China-facing networks and cross-border businesses. Our regularly updated VPS recommendations and practical guides help you make quick, well-informed decisions.