// ssd vps

How to Set Up a LEMP Stack on an SSD VPS: Complete Guide for Maximum Performance

August 06, 2026 · by CLIQHOST

How to Set Up a LEMP Stack on an SSD VPS: Complete Guide for Maximum Performance

If you need a fast, stable, and resource-efficient environment for PHP applications or WordPress, the LEMP stack (Linux, Nginx, MySQL, PHP) is one of the best choices in 2025. Paired with a high-performance SSD VPS, you get a server capable of handling heavy traffic with minimal resource consumption.

This guide walks you through every step — from a blank server to a fully functional, production-ready environment.


What Is the LEMP Stack and Why Does SSD Matter?

LEMP stands for:
- Linux — the operating system (Ubuntu 22.04 in this guide)
- Enginx — the web server (pronounced "engine-x")
- MySQL / MariaDB — the relational database
- PHP — the server-side scripting language

Compared to the classic LAMP stack (with Apache), Nginx consumes up to 40% less RAM at the same traffic level by handling connections asynchronously. On an NVMe VPS, the ultra-fast disk read/write speeds further amplify this advantage — response times for dynamic pages can drop below 50 ms.


Prerequisites

Before you start, make sure you have:
- An active SSD VPS running Ubuntu 22.04 LTS
- SSH access as root or a user with sudo privileges
- A domain with DNS pointing to your server's IP address
- (Optional) An SSL certificate or a plan to issue one via Let's Encrypt


Step 1 — Update the System

First rule on any new server: update packages before installing anything.

sudo apt update && sudo apt upgrade -y

Reboot if kernel updates were applied:

sudo reboot

Step 2 — Install Nginx

sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx

Check the status:

sudo systemctl status nginx

Open the required ports in UFW:

sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo ufw status

Visit http://YOUR_SERVER_IP in a browser — you should see the default Nginx welcome page.

Tip: On a single-core VPS with dedicated resources, Nginx starts in under 2 seconds and idles at less than 5 MB of RAM.


Step 3 — Install MySQL

sudo apt install mysql-server -y
sudo systemctl enable mysql
sudo mysql_secure_installation

The mysql_secure_installation wizard guides you through:
- Setting a root password
- Removing anonymous users
- Disabling remote root login
- Dropping the test database

Create a database and user for your application:

CREATE DATABASE myapp_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'SecurePassword123!';
GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost';
FLUSH PRIVILEGES;

Step 4 — Install PHP-FPM

Nginx does not process PHP natively — it needs PHP-FPM (FastCGI Process Manager).

sudo apt install php8.2-fpm php8.2-mysql php8.2-xml php8.2-mbstring php8.2-curl php8.2-zip php8.2-gd -y
sudo systemctl enable php8.2-fpm
sudo systemctl start php8.2-fpm

Verify the installed version:

php -v

Step 5 — Configure an Nginx Virtual Host

Create the document root:

sudo mkdir -p /var/www/mysite.com/public
sudo chown -R www-data:www-data /var/www/mysite.com

Create the server block configuration:

sudo nano /etc/nginx/sites-available/mysite.com

Recommended content:

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

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }

    client_max_body_size 64M;
    fastcgi_read_timeout 300;
}

Enable the site and test the configuration:

sudo ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Step 6 — Enable HTTPS with Let's Encrypt

Install Certbot:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d mysite.com -d www.mysite.com

Certbot automatically updates the Nginx configuration for HTTPS and schedules certificate renewal. Test renewal with:

sudo certbot renew --dry-run

If you need a commercial certificate with extended validation, CLIQHOST provides dedicated SSL certificates for single domains and wildcard use cases.


Step 7 — Essential Production Optimisations

7.1 — PHP-FPM Tuning

Edit the PHP-FPM pool to match your VPS resources:

sudo nano /etc/php/8.2/fpm/pool.d/www.conf

Recommended settings for a 2 GB RAM VPS:

pm = dynamic
pm.max_children = 20
pm.start_servers = 5
pm.min_spare_servers = 3
pm.max_spare_servers = 8
pm.max_requests = 500

7.2 — Enable Gzip Compression

sudo nano /etc/nginx/nginx.conf

Add inside the http {} block:

gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
gzip_min_length 1024;
gzip_vary on;

7.3 — Static File Caching

location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2)$ {
    expires 30d;
    add_header Cache-Control "public, no-transform";
}

Step 8 — Test the Full LEMP Stack

Create a PHP test file:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/mysite.com/public/info.php

Open http://mysite.com/info.php in your browser. If you see the phpinfo() page, everything is working. Delete the file after testing for security reasons:

sudo rm /var/www/mysite.com/public/info.php

Common Errors and Quick Fixes

Error Likely Cause Fix
502 Bad Gateway PHP-FPM stopped sudo systemctl restart php8.2-fpm
403 Forbidden Wrong file permissions sudo chown -R www-data:www-data /var/www/mysite.com
504 Gateway Timeout Slow PHP script Increase fastcgi_read_timeout
Site not loading on HTTPS Port 443 blocked sudo ufw allow 443

Why Run LEMP on an SSD VPS Instead of Shared Hosting?

On shared cPanel hosting, resources are divided among dozens of users. An SSD VPS gives you:
- Dedicated resources — RAM, CPU, and IOPS reserved exclusively for you
- Full control — custom PHP versions, any Nginx modules you need
- Instant scalability — upgrade in minutes without data migration
- Complete isolation — other sites cannot affect your performance

For teams that prefer not to manage the server themselves, CLIQHOST's server management service covers installation, configuration, and monitoring of your LEMP stack.

For more hands-on guides like this one, visit the CLIQHOST blog.


Conclusion

You now have a fully functional LEMP stack running on an SSD VPS: Nginx serves static requests at maximum speed, PHP-FPM handles application logic, and MySQL stores your data reliably. With a few baseline optimisations — Gzip compression, static caching, and PHP-FPM tuning — your server is ready for real-world traffic.

Browse SSD VPS plans at CLIQHOST or reach out through our contact page to find the configuration that best fits your project.

SHARE
// what clients say

What Our Clients Say

Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.

★★★★★

"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."

AM
Andrei M.
eCommerce owner · Chișinău
★★★★★

"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."

EV
Elena V.
Web agency · Bălți
★★★★★

"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."

DC
Dmitri C.
SaaS founder · Chișinău