Tutorial · wordpress · Published 2026-08-16 · 4 min read

Installing WordPress with WP-CLI

Install WordPress with WP-CLI: download the core, generate wp-config, install the database and a user, and verify the fresh install.

Why scaffold with WP-CLI

A fresh WordPress install is normally a browser form: download, create a wp-config, run wp-admin/install.php and answer the fields. WP-CLI (wp) does the same work from a terminal, which matters when you are provisioning many installs, scripting a staging or VPS setup, or automating a pipeline where a browser never opens. It also leaves a history you can repeat, which makes the next install take seconds instead of minutes.

WP-CLI needs PHP to exist on the server (the php binary) and a writable document root. Check both before starting; the hosting panel versus WP-CLI comparison explains where WP-CLI fits among the alternatives.

Step 1: download WordPress core

From the directory that will become the document root (empty, or ready to receive the release):

wp core download

That downloads the latest stable WordPress into the current directory. Useful flags:

Step 2: create wp-config

WP-CLI can generate wp-config.php from the database details, with a random set of salts:

wp config create --dbname=mydb --dbuser=myuser --dbpass=secret \
  --dbhost=localhost --path=. --skip-check

The --skip-check keeps WP-CLI from trying to connect to the database while creating the file; separate from that, the command generates a standard wp-config.php with unique authentication keys and salts that it never prints to the terminal.

Step 3: install core and the database

With configuration in place, install core against a database that already exists:

wp core install --url="https://example.com" \
  --title="Example site" \
  --admin_user=admin --admin_password="h4rd2guess" --admin_email="[email protected]"

The order matters less than the result: the install writes the options (home and siteurl), creates the default tables, and sets the admin user with a hashed password. WP-CLI prints the resulting site URL on success. Create the database first (wp db create on a host where WP-CLI can create databases, or via your panel), because wp core install expects it to exist.

Step 4: finish the site config

The scaffold leaves two things to attend to:

wp rewrite flush --hard
wp option update timezone_string Europe/London

The rewrite flush is what lets pretty permalinks work (needed before the first non-root page works at /topics/... URLs). The timezone is cosmetic but defaults to UTC in a fresh install. Set the site language, and a default admin plugin set only if your process does it elsewhere.

Verify what the scaffold produced

Troubleshooting the scaffold

Prevention

Treat the scaffold as a repeatable script rather than a one-off: keep the wp core install line in a notes file or a small shell script, so the next environment is installed the same way with no guesswork. WP-CLI's own scripting power is covered in the media WP-CLI guide, and the release pipeline you build around it connects to the staging to live flow.

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services