Back to site

Install WordPress on VPS

Deploy WordPress on a HolyCloud VPS with Nginx, MariaDB, and PHP-FPM; optional WP-CLI.

Install WordPress on VPS

This guide deploys WordPress on a HolyCloud Linux VPS with Nginx, MariaDB, and PHP-FPM. WP-CLI speeds up installation and updates from the command line.

Prerequisites

  • HolyCloud VPS (2 GB RAM minimum recommended)
  • Domain pointing to the VPS IP (A record)
  • Ubuntu 22.04/24.04 or Debian 12, sudo access
  • Ports 80 and 443 open (UFW + HolyCloud panel)

Tip: create a HolyCloud snapshot before going to production.

Step 1: base packages

sudo apt update
sudo apt upgrade -y
sudo apt install -y nginx mariadb-server php8.3-fpm php8.3-mysql php8.3-xml php8.3-curl \
  php8.3-mbstring php8.3-zip php8.3-gd php8.3-intl certbot python3-certbot-nginx

If PHP 8.3 is unavailable, add the Sury/ondrej repository (see PHP/Composer guide) then run apt install again.

Step 2: secure MariaDB

sudo mysql_secure_installation

Create the WordPress database and user:

sudo mysql <<'EOF'
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'MotDePasseBDDFort!';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EOF

Step 3: download WordPress

cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz -C /var/www/
sudo chown -R www-data:www-data /var/www/wordpress
sudo find /var/www/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress -type f -exec chmod 644 {} \;

Configure wp-config.php:

cd /var/www/wordpress
sudo -u www-data cp wp-config-sample.php wp-config.php
sudo -u www-data sed -i "s/database_name_here/wordpress/" wp-config.php
sudo -u www-data sed -i "s/username_here/wpuser/" wp-config.php
sudo -u www-data sed -i "s/password_here/MotDePasseBDDFort!/" wp-config.php

Security keys (generate at https://api.wordpress.org/secret-key/1.1/salt/):

curl -s https://api.wordpress.org/secret-key/1.1/salt/ | sudo -u www-data tee /tmp/salts.txt
# Insérez le contenu dans wp-config.php à la place des define('AUTH_KEY'...)

Step 4: Nginx virtual host

sudo nano /etc/nginx/sites-available/wordpress
server {
    listen 80;
    server_name blog.example.com;
    root /var/www/wordpress;
    index index.php;

    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 ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        expires max;
        log_not_found off;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }
}

Enable the site:

sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Let's Encrypt certificate:

sudo certbot --nginx -d blog.example.com

Step 5: WP-CLI (optional)

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
wp --info

Full CLI install:

cd /var/www/wordpress
sudo -u www-data wp core install \
  --url="https://blog.example.com" \
  --title="Mon site HolyCloud" \
  --admin_user="admin" \
  --admin_password="MotDePasseAdminFort!" \
  --admin_email="[email protected]"

Updates:

sudo -u www-data wp core update
sudo -u www-data wp plugin update --all

Step 6: quick hardening

sudo -u www-data wp config set DISALLOW_FILE_EDIT true --raw
sudo apt install -y fail2ban

Uploads permissions:

sudo -u www-data mkdir -p /var/www/wordpress/wp-content/uploads

Verification

  • Open https://blog.example.com — installer or live site
  • sudo -u www-data wp option get siteurl (with WP-CLI)
  • sudo systemctl status nginx mariadb php8.3-fpm

Need help?

HolyCloud support helps with connectivity and the VPS; WordPress themes/plugins remain with the vendor.