Install WordPress Using Command Line | Step-by-Step Guide

Photo of author
Written By Charlie Giles

Devoted WordPress fan behind CodeCraftWP. Sharing years of web expertise to empower your WordPress journey!

Disclosure: This post may contain affiliate links, which means if you click on a link and make a purchase, I may earn a commission at no additional cost to you.

Installing WordPress using the command line can save time and streamline your workflow. Follow our guide for a detailed step-by-step process, including setting up SSH access, preparing your environment, and running installation commands with WP-CLI.

Install WordPress Using Command Line

Choose Method

When you decide to install WordPress using the command line, the first step is choosing your method. You can opt for a manual approach or leverage automation tools. If you’re a seasoned developer, you might prefer crafting commands by hand, ensuring every detail aligns perfectly with your environment’s needs. But if you value speed and convenience, opting for a pre-configured tool like WP-CLI could save you time and effort.

Prepare Environment

Before diving into the command line installation of WordPress, it’s crucial to set up your environment correctly. First, ensure you have access to an SSH terminal or a Command Prompt/PowerShell window on Windows. This is akin to making sure all the tools are ready for a carpenter before starting a woodworking project.

Next, check if PHP and MySQL (or MariaDB) are installed and running. Think of these as the nails and wood in our analogy—without them, your website won’t stand! You can use simple commands like php -v to verify PHP version and mysql --version for MySQL/MariaDB.

Lastly, make sure you have sufficient permissions to write files and directories on your server. This is similar to ensuring the carpenter has access to all necessary tools in a workshop. If you encounter permission issues, you might need to adjust file and directory permissions using commands like chmod 755 for folders and chown to change ownership.

Run Installation Command

With everything set up, it’s time to run the command that will install WordPress. For beginners, this step can seem a bit daunting, much like starting a complex jigsaw puzzle without seeing the picture on the box. However, once you break it down, it becomes more manageable.

First, navigate to your website’s root directory using the cd command in your terminal or Command Prompt. This is where all the magic will happen!

Next, use the WP-CLI command wp core install. This command initiates the installation process and requires a few parameters: --url, --title, --admin_user, --admin_password, and --admin_email. Think of these as the essential pieces needed to assemble your WordPress site:

  • URL: The full URL where your site will live, like http://yourdomain.com.
  • Title: The name you want for your blog or website.
  • Admin User: A username for the administrator account.
  • Password: A strong password for that admin user.
  • Email: Your email address to complete the setup.

For example:
bash
wp core install --url=http://yourdomain.com --title="My WordPress Site" --admin_user=admin --admin_password=StrongPass123 [email protected]

Once you’ve run this command, WordPress will install itself in your designated directory. It’s like setting the foundation for a house—now all that’s left is to build on it with content and design!


Command-Line Basics for WP Install

SSH Access

Ever wondered how to securely connect to your server? Secure Shell (SSH) is like a secret door that opens up a world of command-line access. To start with SSH, you need an SSH client on your local machine—like PuTTY for Windows or Terminal.app on Mac. Once you have it set up, use the correct credentials to log in to your server. Think of it as entering a code to unlock a safe; if done correctly, you gain full control over the server.

Terminal/Command Prompt

Navigating through the command line is like using a map to explore an unfamiliar city. The terminal (or Command Prompt on Windows) acts as your guide, allowing you to issue commands directly to your system. Just like how you might type “where” to find out your location in a game, typing ls or dir will show you the files and folders in your current directory. It’s powerful because it lets you do everything from creating files to deleting directories with ease.

Permissions Check

Before you can install WordPress using the command line, ensure you have the right permissions—just like how a builder needs permission to access certain areas of a construction site. You can check these by running commands like ls -l in your terminal or using tools like chmod and chown. For instance, if you type whoami, it’s akin to asking who is the current user logged into the server, giving you insight into whether you’re operating with sufficient privileges. Always make sure you have write permissions before proceeding to install WordPress, ensuring that any files created or modified during installation will be saved correctly.


Common Tools for WP CLI

WP-CLI Installation

When setting up your WordPress site using a command-line interface (CLI), one of the first tools you’ll need is WP-CLI. Think of WP-CLI as a supercharged version of your favorite word processor, but designed specifically to work with WordPress sites. Installing it might seem daunting at first, much like unpacking a new computer, but the process is straightforward.

To install WP-CLI, head over to the official website and follow the instructions provided for your operating system. For instance, on Ubuntu or Debian-based systems, you can use a simple command in your terminal:
bash
sudo apt-get update && sudo apt-get install wp-cli -y

Update WP-CLI

Just as you regularly update your software to ensure security and functionality, it’s crucial to keep WP-CLI up-to-date. Outdated tools can lead to vulnerabilities or compatibility issues with newer versions of WordPress. To check if an update is available, simply run:
bash
wp --info

This command provides information about the installed version of WP-CLI, including any updates.

To update WP-CLI, use the following command in your terminal:
bash
wp cli update

Basic Commands Overview

Now that you have a grasp on installing and updating WP-CLI, let’s explore some basic commands that will make your life easier. Just as having a good dictionary can help you with writing, these commands are like the essential tools in your toolkit.

To list all available commands, use:
bash
wp --help

This command gives you an overview of what WP-CLI can do for you.

For example, to create a new user account on your WordPress site, you can run:
bash
wp user create [username] [email] --role=[role] --first-name=[firstname] --last-name=[lastname]

Think of this command as the digital equivalent of inviting someone into your online space.

To update a plugin, use:
bash
wp plugin update [plugin-slug]

Updating themes is similarly straightforward with:
bash
wp theme update [theme-slug]

These commands are like shortcuts to common tasks, allowing you to manage your site more efficiently and effectively.

Leave a Comment