Step-by-step documentation for power users on deploying WordPress manually using SSH and WP-CLI. Learn to manage databases, configurations, and core files without a GUI.

Manual WordPress Deployment via SSH and WP-CLI

While one-click installers are convenient, manual deployment via **WP-CLI** (the command-line interface for WordPress) offers superior control, speed, and scriptability. This guide details the technical workflow for deploying a hardened WordPress environment on a Hovixa VPS using SSH. We assume you already have a functional **LAMP** or **LEMP** stack (Linux, Nginx/Apache, MySQL/MariaDB, PHP) configured.

1. Installing WP-CLI

Before deploying WordPress, you must install the WP-CLI binary. This tool interacts directly with your WordPress files and database using PHP.

# Download the Phar archive
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

# Verify and make it executable
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
    

Verify the installation by running wp --info.

2. Preparing the Database

WordPress requires a dedicated database and user. Using the command line is more efficient than using phpMyAdmin for this task.

# Access MySQL
mysql -u root -p

# Execute SQL commands
CREATE DATABASE wp_production DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD_HERE';
GRANT ALL PRIVILEGES ON wp_production.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
    

3. Downloading and Configuring WordPress

Navigate to your web root (e.g., /var/www/html) and use WP-CLI to pull the core files and generate the wp-config.php file.

  1. Download: wp core download
  2. Create Config:
    wp config create --dbname=wp_production --dbuser=wp_user --dbpass=STRONG_PASSWORD_HERE --dbhost=localhost --dbprefix=hvxa_
                
    Note: Changing the default wp_ prefix to something like hvxa_ provides a minor security layer against automated SQL injection scripts.

4. Finalizing the Installation

Run the installation script programmatically. This circumvents the "Famous 5-Minute Install" web UI entirely.

wp core install --url="https://example.com" --title="My Hovixa Site" --admin_user="admin_dev" --admin_password="SECURE_PASSWORD" --admin_email="[email protected]"
    

5. Post-Deployment Optimization

Use WP-CLI to perform immediate maintenance and security tasks:

  • Search and Replace: If you are migrating from a dev URL: wp search-replace 'dev.example.com' 'example.com'.
  • Plugin Management: wp plugin install akismet wordfence --activate.
  • Permissions Fix: Ensure the web server (www-data) owns the files: chown -R www-data:www-data /var/www/html.

6. Technical Implementation Details

Action WP-CLI Command
Update Core wp core update
Database Export wp db export backup.sql
Flush Cache wp cache flush
Regenerate Thumbnails wp media regenerate --yes
  • Security: Always run WP-CLI as a non-root user for security (e.g., sudo -u www-data wp ...). Running WP-CLI as root is discouraged by the application and requires the --allow-root flag.
  • Memory Limits: Large operations (like bulk image regeneration) may require increasing your memory_limit in php.ini.
  • Automation: You can wrap these commands in a bash script to deploy a fully configured WordPress instance on a new Hovixa VPS in under 30 seconds.

Sysadmin Tip: Use the command wp cron event run --due-now to force WordPress to process scheduled tasks immediately. This is invaluable for troubleshooting stuck email notifications or scheduled posts.

Was this answer helpful? 0 Users Found This Useful (0 Votes)