sudo apt update && sudo apt upgrade -y
sudo apt install nginx -y
sudo systemctl enable --now nginx
Check status:
systemctl status nginx
Modern WordPress requires PHP 8.x.
sudo apt install php-fpm php-mysql php-xml php-gd php-curl php-mbstring php-zip php-intl php-soap php-bcmath -y
Check PHP version:
php -v
Install:
sudo apt install mysql-server -y
Secure MySQL:
sudo mysql_secure_installation
Create DB:
sudo mysql
Inside MySQL:
sql
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvf latest.tar.gz
sudo mv wordpress /var/www/wordpress
Set permissions:
sudo chown -R www-data:www-data /var/www/wordpress
sudo chmod -R 755 /var/www/wordpress
Create config:
sudo nano /etc/nginx/sites-available/wordpress
Paste:
nginx
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/wordpress;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg)$ {
expires max;
log_not_found off;
}
}
Enable site:
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Copy sample config:
cd /var/www/wordpress
cp wp-config-sample.php wp-config.php
Edit:
nano wp-config.php
Update DB settings:
php
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'StrongPassword' );
define( 'DB_HOST', 'localhost' );
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Auto-renew test:
sudo certbot renew --dry-run
Visit:
Code
http://yourdomain.com
Set:
Done — WordPress is live.
Install Redis:
bash
sudo apt install redis-server php-redis -y
sudo systemctl enable --now redis-server
Add to wp-config.php:
php
define( 'WP_REDIS_HOST', '127.0.0.1' );