How can we help?

Search our guides and tutorials, or browse the categories below.

How to Install WordPress on Ubuntu VPS

181 views Markdown

 

  1. Update Your Server

sudo apt update && sudo apt upgrade -y

  1. Install Nginx

sudo apt install nginx -y

sudo systemctl enable --now nginx

Check status:

systemctl status nginx

  1. Install PHP & Required Extensions

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

  1. Install MySQL & Create Database

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;

  1. Download WordPress

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

  1. Configure Nginx Server Block

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

  1. Configure WordPress

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' );

  1. Enable HTTPS (Let’s Encrypt SSL)

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

  1. Complete Installation in Browser

Visit:

Code

http://yourdomain.com

Set:

  • Site title
  • Admin username
  • Admin password
  • Email

Done — WordPress is live.

  1. Optional: Redis Cache for High Performance

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' );

 

Was this helpful?

Thanks for your feedback!

Still Need Help?

Our support team is here around the clock for anything you can't find above.