What I needed was a reliable method to build WooCommerce sites in minutes, not hours or days.

When clients need a fast way to order marketing materials or simple e-commerce products, setting up WordPress manually can slow things down. I already had vendors, SKUs, and payment flows ready, That’s where WP-CLI shines.

Using nothing but the terminal, you can deploy WordPress, configure your database, install WooCommerce, activate a theme, and prepare your store for products—all without touching a GUI.

Table of Contents

Why WP-CLI Is the Fastest Way to Deploy WooCommerce

WP-CLI is a command-line interface that allows you to install, configure, and manage WordPress programmatically. That means:

  • Lightning-fast setup
  • Repeatable and scriptable
  • Zero GUI needed
  • Ideal for agencies deploying WooCommerce often

If you want a fast WooCommerce setup and a consistent WordPress developer workflow, WP-CLI is essential.

Server Requirements for a CLI-Only Setup

Before you begin, make sure you have:

  • SSH access
  • MySQL or MariaDB
  • PHP + Apache/Nginx
  • WP-CLI installed (wp --info)
  • A DB-privileged user

If WP-CLI is not installed yet, follow the official installation guide @ https://wp-cli.org/

Step 1: SSH Into Your Server

ssh username@yourserver.com

Navigate into the directory where your new WordPress + WooCommerce site will live:

cd /var/www/
mkdir example-store
cd example-store

Replace /var/www/ and example-store with the paths you use for your hosting environment.

Step 2: Create the MySQL Database from the CLI

Use the MySQL client to create a database, a user, and assign privileges—all from the terminal:

mysql -u root -p -e "
  CREATE DATABASE storedb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  CREATE USER 'storeuser'@'localhost' IDENTIFIED BY 'strongpassword';
  GRANT ALL PRIVILEGES ON storedb.* TO 'storeuser'@'localhost';
  FLUSH PRIVILEGES;
"

Update storedb, storeuser, and strongpassword to match your project.

Step 3: Download WordPress with WP-CLI

From inside your project directory:

wp core download

WP-CLI will download the latest stable version of WordPress into the current folder.

Step 4: Generate wp-config.php

Use WP-CLI to create your wp-config.php file using the database credentials you just set up:

wp config create \
  --dbname=storedb \
  --dbuser=storeuser \
  --dbpass=strongpassword \
  --dbhost=localhost \
  --dbprefix=wp_

This keeps your WordPress configuration consistent and avoids typos.

Step 5: Install WordPress (Fully Automated)

Run the core install command to set your site URL, name, and admin credentials in one shot:

wp core install \
  --url="https://example.com" \
  --title="Example Store" \
  --admin_user="admin" \
  --admin_password="supersecret" \
  --admin_email="info@example.com"

Handling multi-word titles

If your site title contains spaces or special characters, keep it wrapped in quotes (single or double both work):

--title="My Awesome WooCommerce Store"

At this point, you already have a working WordPress install.

Step 6: Install and Activate a WooCommerce-Ready Theme

Install a lightweight, WooCommerce-ready theme. In this example, we’ll use Flash, but you can swap in any theme from WordPress.org:

wp theme install flash --activate

You can also list and search themes via WP-CLI:

wp theme search woocommerce

Step 7: Install Required Plugins

Install WooCommerce

wp plugin install woocommerce --activate

Install Page Builder or Utility Plugins (Optional)

For example, SiteOrigin Page Builder:

wp plugin install siteorigin-panels --activate

You can install and activate multiple plugins in a single command:

wp plugin install \
  woocommerce \
  siteorigin-panels \
  jetpack \
  --activate

This is a simple way to standardize your default stack for new WooCommerce projects.

Step 8: Create Custom User Roles (Optional)

If you want to restrict certain products or categories to specific clients or partners, you can create custom WordPress roles with WP-CLI.

Example: role for a specific B2B client:

wp role create acmeclient "ACME Client"

Then you can use WooCommerce extensions, membership plugins, or catalog visibility options to control what each role can see or purchase.

Step 9: Flush Rewrite Rules

Always flush rewrite rules after activating WooCommerce, especially in a fresh install:

wp rewrite flush --hard

This makes sure your permalinks and WooCommerce endpoints work as expected.

Step 10: Single-Site Quickstart Script

If you want a copy-paste deployment script for a single WooCommerce store, here’s a simple example. You can paste this into your terminal (updating values) or convert it into a .sh file.

# --- WooCommerce Quickstart (Single Site) ---

# Variables
PROJECT_DIR="/var/www/example-store"
DB_NAME="storedb"
DB_USER="storeuser"
DB_PASS="strongpassword"
DB_HOST="localhost"
SITE_URL="https://example.com"
SITE_TITLE="Example Store"
ADMIN_USER="admin"
ADMIN_PASS="supersecret"
ADMIN_EMAIL="info@example.com"

# Create project directory
mkdir -p "$PROJECT_DIR"
cd "$PROJECT_DIR"

# Download WordPress
wp core download

# Create database (requires root or privileged MySQL user)
mysql -u root -p -e "
  CREATE DATABASE IF NOT EXISTS ${DB_NAME} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  CREATE USER IF NOT EXISTS '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';
  GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'localhost';
  FLUSH PRIVILEGES;
"

# Generate wp-config
wp config create \
  --dbname="$DB_NAME" \
  --dbuser="$DB_USER" \
  --dbpass="$DB_PASS" \
  --dbhost="$DB_HOST" \
  --dbprefix="wp_"

# Install WordPress
wp core install \
  --url="$SITE_URL" \
  --title="$SITE_TITLE" \
  --admin_user="$ADMIN_USER" \
  --admin_password="$ADMIN_PASS" \
  --admin_email="$ADMIN_EMAIL"

# Install theme and plugins
wp theme install flash --activate
wp plugin install woocommerce --activate

# Optional plugins
wp plugin install siteorigin-panels --activate

# Flush rewrites
wp rewrite flush --hard

# Done
wp option get siteurl

Update variables at the top for each new project and you can deploy a store in just a few commands.

Reusable WP-CLI Deployment Script

If you prefer a reusable, downloadable starter script, save the following as wpcli-woocommerce-bootstrap.sh in your local machine or server.

#!/usr/bin/env bash

# wpcli-woocommerce-bootstrap.sh
# Reusable script to bootstrap a WordPress + WooCommerce site using WP-CLI.

set -e

# --- Configuration (edit these for each project) ---
PROJECT_DIR="/var/www/example-store"
DB_NAME="storedb"
DB_USER="storeuser"
DB_PASS="strongpassword"
DB_HOST="localhost"
SITE_URL="https://example.com"
SITE_TITLE="Example Store"
ADMIN_USER="admin"
ADMIN_PASS="supersecret"
ADMIN_EMAIL="info@example.com"
THEME_SLUG="flash"
EXTRA_PLUGINS=("siteorigin-panels")

# --- Script ---

echo "Creating project directory: $PROJECT_DIR"
mkdir -p "$PROJECT_DIR"
cd "$PROJECT_DIR"

echo "Downloading WordPress core..."
wp core download

echo "Creating database (if not exists)..."
mysql -u root -p -e "
  CREATE DATABASE IF NOT EXISTS ${DB_NAME} CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  CREATE USER IF NOT EXISTS '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';
  GRANT ALL PRIVILEGES ON ${DB_NAME}.* TO '${DB_USER}'@'localhost';
  FLUSH PRIVILEGES;
"

echo "Generating wp-config.php..."
wp config create \
  --dbname="$DB_NAME" \
  --dbuser="$DB_USER" \
  --dbpass="$DB_PASS" \
  --dbhost="$DB_HOST" \
  --dbprefix="wp_"

echo "Running WordPress core install..."
wp core install \
  --url="$SITE_URL" \
  --title="$SITE_TITLE" \
  --admin_user="$ADMIN_USER" \
  --admin_password="$ADMIN_PASS" \
  --admin_email="$ADMIN_EMAIL"

echo "Installing and activating theme: $THEME_SLUG"
wp theme install "$THEME_SLUG" --activate

echo "Installing and activating WooCommerce..."
wp plugin install woocommerce --activate

echo "Installing extra plugins..."
for PLUGIN in "${EXTRA_PLUGINS[@]}"; do
  wp plugin install "$PLUGIN" --activate
done

echo "Flushing rewrite rules..."
wp rewrite flush --hard

echo "All done!"
wp option get siteurl

To use this starter script:

  1. Save it as wpcli-woocommerce-bootstrap.sh.
  2. Make it executable:

    chmod +x wpcli-woocommerce-bootstrap.sh
    
  3. Run it:

    ./wpcli-woocommerce-bootstrap.sh
    
  4. Update the variables at the top for each new WooCommerce site.

Final Thoughts and Next Steps

If you build WordPress or WooCommerce sites regularly, WP-CLI turns setup into a fast, repeatable process. No more clicking through installers for every client site—just a consistent, scriptable workflow that you can version, share, and improve over time.

To explore everything WP-CLI can do—users, media, posts, cron jobs, database search-replace, and more—see the full command reference:

https://developer.wordpress.org/cli/commands/

With a strong CLI-first workflow, spinning up new WooCommerce sites becomes fast, predictable, and scalable—exactly what freelancers, agencies, and in-house teams need.