urZONE / Deployment Guide

Install WordPress on a fresh VM

Go from a clean Ubuntu virtual machine to a running WordPress site with Apache, MariaDB, and PHP. Follow the steps in order, and use the Copy buttons to send only the commands you need to your terminal.

01 Prepare 02 Deploy 03 Manage

Before you begin

Clean VM

Start with a fresh Ubuntu Server LTS virtual machine with root or sudo access and a working internet connection. Do not use a VM that already runs another web server or control panel.

Recommended resources

At least 1 vCPU, 2 GB of RAM, and 20 GB of disk space is a comfortable starting point for a small site. Allow more for media, plugins, and backups.

Network

Open TCP ports 80 and 443 on the VM and on any provider or hypervisor firewall. Point your domain’s A record at the VM if you plan to use HTTPS.

Run with care: These commands install system packages and change web server settings with administrative privileges. Use a VM you control, and take a snapshot first.

Step 01

Connect and update

Sign in to the VM as root and update its packages. Replace the example IP address with your own.

Local terminal · SSH
ssh root@YOUR_SERVER_IP
Root terminal · Ubuntu
apt update && apt upgrade -y

If the update requires a reboot, reboot first, reconnect, and then continue.

Step 02

Install Apache, MariaDB, and PHP

This installs the web server, the database, and the PHP modules WordPress commonly needs.

Root terminal · Web stack
apt install -y apache2 mariadb-server php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-zip php-intl php-imagick curl unzip
a2enmod rewrite
systemctl restart apache2
Step 03

Create the database

Create a database and a dedicated user for WordPress. Replace YOUR_DB_PASSWORD with a strong password before running, and keep it for Step 05.

Root terminal · MariaDB
mariadb -e "CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'YOUR_DB_PASSWORD';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;"

Before running: Replace the placeholder locally, never publish your real password, and be aware that passwords typed into commands may remain in shell history.

Step 04

Download WordPress

Download the latest release from wordpress.org, place it in the web root, and give Apache ownership of the files.

Root terminal · WordPress files
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
rm -f /var/www/html/index.html
cp -a wordpress/. /var/www/html/
chown -R www-data:www-data /var/www/html
find /var/www/html -type d -exec chmod 755 {} \;
find /var/www/html -type f -exec chmod 644 {} \;
Step 05

Connect WordPress to the database

Copy the sample configuration, then edit it and enter your database details. Set DB_NAME to wordpress, DB_USER to wpuser, and DB_PASSWORD to the password you chose.

Root terminal · Configuration
cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
nano /var/www/html/wp-config.php

Replace the placeholder security keys too. WordPress provides a generator at api.wordpress.org/secret-key/1.1/salt. In nano, press Ctrl+O then Enter to save, and Ctrl+X to exit.

Step 06

Allow permalinks

Let WordPress use pretty URLs by allowing .htaccess overrides for the web root.

Root terminal · Apache
cat > /etc/apache2/conf-available/wordpress.conf <<'EOF'
<Directory /var/www/html>
    AllowOverride All
</Directory>
EOF
a2enconf wordpress
systemctl reload apache2
Step 07

Finish in your browser

Open this address, choose a language, and complete the famous five-minute install by entering your site title and creating an administrator account:

http://YOUR_SERVER_IP/

Replace YOUR_SERVER_IP with your VM’s actual IP address. Use a strong, unique administrator password.

Recommended

Turn on HTTPS

If your domain already points to this VM, install a free Let’s Encrypt certificate. Replace example.com with your domain.

Root terminal · Certbot
apt install -y certbot python3-certbot-apache
certbot --apache -d example.com -d www.example.com

Keep building

Keep WordPress, themes, plugins, and the operating system updated, use unique administrator credentials, and take regular backups of both /var/www/html and the database.

References: WordPress installation guide · WordPress requirements · Certbot