LEMP Stack (Linux + Nginx + MySQL + PHP)
This guide installs WordPress on a VPS with Ubuntu 22.04 using the LEMP stack, the fastest combination for WordPress.
Step 1 — Install Nginx, MySQL, and PHP
apt update && apt upgrade -y
apt install nginx mysql-server php8.2-fpm php8.2-mysql php8.2-xml php8.2-curl php8.2-mbstring php8.2-zip php8.2-gd -y
systemctl start nginx mysql php8.2-fpm
systemctl enable nginx mysql php8.2-fpm
apt install nginx mysql-server php8.2-fpm php8.2-mysql php8.2-xml php8.2-curl php8.2-mbstring php8.2-zip php8.2-gd -y
systemctl start nginx mysql php8.2-fpm
systemctl enable nginx mysql php8.2-fpm
Step 2 — Create MySQL Database
mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'TuContraseñaSegura';
GRANT ALL ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'TuContraseñaSegura';
GRANT ALL ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 3 — Download and Install WordPress
cd /var/www
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
mv wordpress yourdomain
chown -R www-data:www-data yourdomain
chmod -R 755 yourdomain
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
mv wordpress yourdomain
chown -R www-data:www-data yourdomain
chmod -R 755 yourdomain
Step 4 — Configure Nginx for WordPress
Create the file /etc/nginx/conf.d/yourdomain.conf:
server {
listen 80;
server_name yourdomain.com;
root /var/www/yourdomain;
index index.php;
location / { try_files $uri $uri/ /index.php?$args; }
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
listen 80;
server_name yourdomain.com;
root /var/www/yourdomain;
index index.php;
location / { try_files $uri $uri/ /index.php?$args; }
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Then: nginx -t && systemctl reload nginx
Step 5 — Complete Installation from the Browser
Go to http://yourdomain.com and follow the WordPress installation wizard using the database details from Step 2.
✅ WordPress installed. Access the panel at
yourdomain.com/wp-admin. To add HTTPS, install Certbot: apt install certbot python3-certbot-nginx -y && certbot --nginx -d yourdomain.com