WP-CLI Install WordPress: Easy Guide

Bulletproof Backups for Your WordPress Website

Fortify your business continuity with foolproof WordPress backups. No data loss, no downtime — just secure, seamless operation.

wp-cli install wordpress

Are you clicking through WordPress installation screens for a staging site? Trying to build a WordPress site from scratch? The WP-CLI install WordPress command makes it much easier. 

This guide walks you through using WP-CLI for a WordPress installation process. By the end, you’ll have the exact commands to install WordPress in under 60 seconds.

TL;DR: Installing WordPress doesn’t have to be complicated. Just run these commands on WP-CLI:

wp core download  
wp config create –dbname=DATABASE –dbuser=USER –dbpass=PASSWORD
wp core install –url=YOURSITE.COM –title=”SITE” –admin_user=ADMIN –admin_password=PASSWORD –admin_email=EMAIL

Prerequisites for WP-CLI WordPress Installation

Before diving into the installation commands, you’ll need to ensure your server environment is properly configured. Think of these prerequisites as laying the foundation.

  • SSH Access to Your Server: Get comfortable with using SSH (Secure Shell) and running command-line tools. Most quality web hosts provide SSH access, though some budget shared hosting providers may restrict it. 
  • PHP and WP-CLI Installation: WordPress requires PHP (version 7.4 or higher) to run. You can do all this SSH terminal too. Additionally, you need WP-CLI installed too.
  • Web server: A functioning web server is required. This tutorial uses Apache, but the steps work with other web servers too (like Nginx or LiteSpeed).
  • Stable internet connection: A reliable network connection is essential. Interruptions during installation can cause delays, corrupt files, or force you to restart.
  • Database and User Setup: Every WordPress site needs a dedicated MySQL database and a user account with permission to access it. If you’re using a hosting control panel like cPanel, you can create these through the “MySQL Databases” section with just a few clicks. 

Install WordPress with WP-CLI Commands

Note: The instructions in this article are specific to MacOS and Linux users. The commands will vary slightly for Microsoft users.

After creating a database and once the server environment is configured and prerequisites met, you’re ready to execute the actual WordPress installation. Here are the commands that you need: 

  1. Connect to your web server: Connect to your web server via SSH:
ssh your_ssh_user@your.server.com

Replace your_ssh_user and your.server.ip with your credentials. 

  1. Navigate to Your Web Root: This could vary depending on your web server. But, in our case it’s the public_html folder. This is where your WordPress site files will live. 
cd ~/public_html       

The file should be empty. 

  1. Download WordPress Core: Next up, download the WordPress files. 
wp core download
  1. Create the wp-config.php file: When you download the WordPress core files, you’’re downloading the sample wp-config.php file. So, you now have to generate the actual file.  
wp config create \
  1. Configure the database: Next up, you have to connect your WordPress installation to the database you created. You essentially have to add your db username, name and password in the appropriate fields in wp-config.php
  --dbname="your_database_name" \
--dbuser="your_db_username" \
  --dbpass="your_db_password" \
  1. Install WordPress: At this stage, you’re connecting to the database and generating database tables. You also have to add details like the URL, the title and create an admin user, 
wp core install \
--url="https://example.com" \
  --title="My WordPress Site" \
  --admin_user="adminusername" \
  --admin_password="Strong-Password-Here" \
  --admin_email="you@example.com" \
  --skip-email
  1. Verify Installation: On your browser check that the URL you added is now displaying a WordPress site. 

Troubleshooting Common WP-CLI WordPress Installation Issues

Even with careful preparation, WP-CLI WordPress installations sometimes encounter roadblocks. The good news is that most issues fall into three predictable categories:

“Error Establishing Database Connection”

Error establishing database connection” is an error that appears when WordPress cannot connect to your MySQL database. This is usually due to incorrect credentials or connection settings:

Solution Steps:

  • Double-check your database name, username, and password for typos
  • Verify the database actually exists by logging into MySQL: mysql -u your_user -p
  • Test database connectivity: wp db check (if wp-config.php exists)
  • Add the database host explicitly: wp config create –dbhost=localhost (or your specific host)
  • For remote databases, use the full hostname: –dbhost=mysql.yourhost.com:3306

Some hosting providers use non-standard database hosts or ports, so check your hosting control panel for the exact connection details if localhost doesn’t work.

“WP-CLI Command Not Found”

This error means your system cannot locate the WP-CLI executable, indicating an installation or PATH configuration issue:

Solution Steps:

  • Check if WP-CLI is installed: which wp (should return a file path)
  • Download WP-CLI if missing: curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  • Make it executable: chmod +x wp-cli.phar
  • Move to system PATH: sudo mv wp-cli.phar /usr/local/bin/wp
  • Test installation: wp –info

If you’re on shared hosting, WP-CLI might be installed in a non-standard location. Contact your host or check their documentation for the correct path.

File Permission Errors

WordPress permission errors prevent WordPress from creating or modifying files, causing installation failures or runtime issues:

Solution Steps:

  • Set correct ownership: chown -R www-data:www-data /path/to/wordpress
  • For Nginx servers: chown -R nginx:nginx /path/to/wordpress
  • For cPanel/shared hosting: chown -R username:username /path/to/wordpress
  • Set proper permissions: find /path/to/wordpress -type d -exec chmod 755 {} \;
  • Set file permissions: find /path/to/wordpress -type f -exec chmod 644 {} \;

The correct user varies by server configuration—www-data for Apache, nginx for Nginx, or your hosting account username for shared hosting. When in doubt, check existing file ownership with ls -la to see what user your server expects.

Final Thoughts

Congratulations on installing WordPress! You’ve just set up the foundation for your website, and that’s no small feat. Now you can log in, explore the dashboard, and start shaping your site into whatever you envision — whether that’s a blog, business page, or online store. This is where the fun (and creativity) begins.

WordPress plugins are your next best friends now that your site is up and running. Start by installing a few essential plugins like BlogVault. That way, no matter what changes you make while experimenting with themes, settings, or new features, you’ll always have a clean restore point ready to bring your site back in minutes. Think of it as your safety net while you explore and build.

FAQs

What is WP CLI in WordPress?

WP-CLI (WordPress Command Line Interface) is an official command-line tool for managing WordPress installations without using a web browser. It allows you to perform WordPress tasks like installing core files, managing plugins and themes, updating content, and configuring settings through terminal commands. Instead of clicking through admin dashboards, you can execute powerful WordPress operations with simple text commands like wp plugin install or wp user create.

What is a CLI install?

A CLI install refers to installing software (in this case, WordPress) using command-line interface tools rather than graphical installers or web-based setup wizards. With WordPress CLI installation, you run text commands in a terminal to download WordPress files, configure database connections, and set up your site—all without opening a browser. This method is faster, scriptable, and preferred by developers because it can be automated and repeated consistently across multiple installations.

What is the WP CLI folder?

The WP-CLI folder refers to the directory where WP-CLI stores its configuration files, cache, and packages. On most systems, this is located at ~/.wp-cli/ in your home directory. This folder contains:

config.yml: Global WP-CLI configuration settings
packages/: Directory for installed WP-CLI packages and extensions
cache/: Temporary files and downloaded data to speed up operations

You can also create a wp-cli.yml file in individual WordPress project directories to set project-specific configurations. The WP-CLI folder structure helps organize settings and ensures commands work consistently across different WordPress installations on your system.

What do you need before installing WordPress?

Before installing WordPress (especially with WP-CLI), you should have:

1. Stable internet connection – To ensure a smooth download and avoid file corruption.

2. WP-CLI installed – Check with:

3. Database ready – Create one in advance and note the database name, database username, database password, and the database host (localhost or another hostname provided by your host)

4. A functioning web server – Apache, Nginx, or LiteSpeed with PHP and MySQL/MariaDB.

What’s the command for downloading WordPress using WP-CLI?

The basic command is:

wp core download

This fetches the latest version of WordPress core files into your current directory, ready for configuration and installation.

Tags:

You may also like


learndash vs tutor lms
LearnDash vs Tutor LMS: Which Should You Choose?

Stuck choosing a platform for your online course? The LearnDash vs Tutor LMS debate is a critical decision for any creator. Picking the right one means a smooth launch and…

learndash vs learnpress
Learndash vs LearnPress: Which One Should You Choose?

Your search for Learndash vs LearnPress ends here. This single decision impacts your budget, your students’ experience, and your ability to scale. Picking the wrong plugin means hitting a wall…

How do you update and backup your website?

Creating Backup and Updating website can be time consuming and error-prone. BlogVault will save you hours everyday while providing you complete peace of mind.

Updating Everything Manually?

But it’s too time consuming, complicated and stops you from achieving your full potential. You don’t want to put your business at risk with inefficient management.

Backup Your WordPress Site

Install the plugin on your website, let it sync and you’re done. Get automated, scheduled backups for your critical site data, and make sure your website never experiences downtime again.