
Editorial illustration.
Originally published 20 June 2023; rewritten and reviewed on 15 October 2026.
A terminal installation is attractive because every step can be recorded, scripted, and repeated across staging and production VPS nodes. The downside is how easy it is to copy-paste commands from a six-year-old blog post, hit a permission error during plugin installation, and “fix” it with chmod -R 777. Establish the host layout and process ownership first, and the rest of the setup becomes predictable.
Prepare the supported platform
Start by picking a web server, PHP version, and database that match the WordPress release you intend to run. On Ubuntu 24.04 LTS, that typically means Nginx, PHP 8.3 FPM, and MariaDB. Check the official WordPress requirements rather than assuming an older package list still applies.
sudo apt update
sudo apt install -y nginx mariadb-server \
php8.3-fpm php8.3-mysql php8.3-curl php8.3-gd \
php8.3-mbstring php8.3-xml php8.3-zip php8.3-intl unzip
Next, create a dedicated database and a least-privilege user inside MariaDB. Avoid reusing root or sharing one database user across multiple client sites on the same server—if one site gets compromised through an outdated plugin, you do not want lateral movement into every other database.
CREATE DATABASE wp_mysite CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_mysite_user'@'localhost' IDENTIFIED BY 'use-a-strong-generated-password';
GRANT ALL PRIVILEGES ON wp_mysite.* TO 'wp_mysite_user'@'localhost';
FLUSH PRIVILEGES;
Generate the password with openssl rand -base64 24 and keep it out of public runbooks or shared shell history (HISTCONTROL=ignorespace helps when typing secrets interactively).
Install under the intended account with WP-CLI
Instead of downloading zip archives into /tmp as root, install WP-CLI globally and run WordPress commands as your deployment user (or www-data where appropriate):
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
Create the web root, assign ownership to your deploy user and the www-data group, and pull WordPress core cleanly:
sudo mkdir -p /var/www/mysite
sudo chown -R $USER:www-data /var/www/mysite
cd /var/www/mysite
wp core download
wp config create --dbname=wp_mysite --dbuser=wp_mysite_user --dbpass='...' --dbhost=localhost
wp core install \
--url="https://example.com" \
--title="My Site" \
--admin_user="zul_admin" \
--admin_password='...' \
--admin_email="admin@example.com"
Once installed, lock down filesystem permissions so the web server (www-data) can read everything, write only where it genuinely needs to (such as wp-content/uploads), and cannot modify core PHP files on a whim:
sudo chown -R $USER:www-data /var/www/mysite
find /var/www/mysite -type d -exec chmod 750 {} \;
find /var/www/mysite -type f -exec chmod 640 {} \;
sudo chmod -R 770 /var/www/mysite/wp-content/uploads
If you prefer one-click plugin updates from wp-admin rather than deploying via WP-CLI or CI, you will need wp-content writable by www-data—just make that an explicit operational choice rather than an accident.
Configure Nginx and verify the full service
Point an Nginx server block at /var/www/mysite, pass .php requests to php8.3-fpm.sock, and block direct web access to sensitive files:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/mysite;
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 ~* /(?:wp-config\.php|xmlrpc\.php|readme\.html|license\.txt) {
deny all;
}
location ~* /wp-content/uploads/.*\.php$ {
deny all;
}
}
Enable the site, test with sudo nginx -t, reload Nginx, and issue an SSL certificate via sudo certbot --nginx -d example.com -d www.example.com.
Before handing the site over, run wp core verify-checksums to confirm core files have not been tampered with, test permalink saving, upload an image to confirm wp-content/uploads permissions work, and check wp cron event list to verify scheduled jobs run. Finally, test a database dump (wp db export) and restore on a scratch database—an installation is only production-ready when you know how to recover it.