Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    Install WordPress through WP-CLI in few seconds

    Install WordPress through WP-CLI – Everyone is probably familiar with WordPress and its renowned 5-minute install routine. It’s simple and works without fuss. But when you have multiple sites to manage, repeating the same routine can waste plenty of time which you could have used elsewhere.

    This is where WP-CLI, a powerful command line tool with which you can manage WordPress, can help. This tutorial covers how to install WP-CLI and how to perform some common, practical tasks using it.

    Install WP-CLI

    1. WP-CLI is available as a PHP Archive file (.phar). You can download it using either wget or curl commands:


    2. You need to make this .phar file executable and move it to /usr/local/bin so that it can be run directly:

    3. Check if it is installed properly:

      You should see a similar output like that displayed above, which means you can proceed:

    You can use the above three steps for upgrading WP-CLI as well.

    Basics of WP-CLI

    Before moving on, let’s learn some basics of how WP-CLI works. This will help you feel comfortable with the upcoming steps.

    So far, we have seen WP-CLI accessed through the main command, wp. You can follow the main command with nested subcommands. For example, we have a command to download WordPress, which is:

    Here wp is the main command while core and download are its nested subcommands. Nesting subcommands can extend one or two levels.

    WP-CLI also comes with a detailed help section, which displays all the commands you might need. To access help:

    The output should resemble:

    : is a prompt that, with subcommands, can help you navigate through this help menu. Up and down arrow keys will let you scroll through the entire help command list. Typing q will exit the help menu. For additional details on how to further navigate through the complete help section, you can always type h at the above prompt.

    You can use the enabled bash completion to demonstrate WP-CLI’s readily available command list. Simply type wp and press tab twice. You will see the list of available commands. Now, type wp core and press tab twice. You will see a list of commands that can be used with core. This double tabbing after a command can be repeated for any primary or subcommand.

    Install WordPress

    Setting up Database

    1. Before you proceed, you need to setup a database. Log in to the MySQL server, replacing user with your MySQL username:

    2. Create a database:
    3. Grant required privileges to the database for the mysql user to which WordPress will permit database access. Replace user and password with those of the permitted mysql user:
    4. Type quit to exit the MySQL command line.

    Main Install

    1. Move to the Apache test directory:
    2. Next, download the WordPress files.
    3. Create a wp-config.php file:

      dbhost and dbprefix are entirely optional and can be omitted unless you need to change their default values.
    4. Run the installation:

    Your WordPress blog is now ready for use.

    Common Commands

    Installing Themes with WP-CLI

    Importing and installing themes is much quicker through WP-CLI than going into WordPress admin, searching and then activating it.

    It connects your server directly to the WordPress theme repository and imports the theme in a matter of a few seconds. For example, to install a theme like TwentyTen, we will use the following command:

    To activate the themes on your WordPress website, you will need to use the following command:

    Installing Plugins with WP-CLI

    Just like the themes, plugins can also be installed right from the official repository. Installation is seamless and takes almost no time.

    The above command will install the WooCommerce plugin on your website. To activate it, we will use the command:

    Similarly, to deactivate any plugin, the command becomes:

    Updating WordPress Core, Themes and Plugins with WP-CLI

    Repetitive and often time consuming task of updating the WordPress core, themes and plugins can be easily carried out through the command line.

    To update the WordPress core to the latest stable release of WordPress, the command is:

    If you want to update to a specific version, for example you have WordPress 3.7 and want to move to WordPress 4.0 instead of WordPress 4.3, use the command:

    Or, if for any reason you want to revert back your WordPress site to the previous version, the command is:

    To update plugins, you can either define one plugin to update or better still.

    Update all the plugins in one go.

    A similar method applies to the themes. You can update WordPress themes through WP-CLI with following command

    Update all the themes in one go.


    WP-CLI is indeed a powerful tool that can be used to manage your WordPress sites through the command line. There are also many more commands to manage your database, take backups, manage posts, comments and WordPress multisite It definitely speeds up your tasks, and makes it really easy to manage the sites. Luckily, there are hosting providers that provide WP-CLI by default on their WordPress installations (you can find a maintained list here).

    . . .


    Add Your Comment

    Be the first to comment.

    Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again