Installing WordPress using Command Line on Windows

There is a less known geek way of installing WordPress. It’s done using the command line with the help of WP-CLI, a command line interface for WordPress. WP-CLI is a free tool available under MIT license that works on the command line.

WP-CLI can help you manage your WordPress installation. WP-CLI is actually a set of tools which can perform all sorts of WordPress stuff like installing WordPress, performing core update, plugin update, theme update, database backup and much more.

In this tutorial, we will use WP-CLI to install WordPress on Windows. Let’s begin!

What you need

Make sure that you have setup your local web server. Check the environment variables to make sure that PHP and MySQL paths are available. Also, create a database user and a database needed for WordPress.

Installing WP-CLI on Windows

First download a copy of WP-CLI from the official home page. It’s a .phar file – a PHP executable file.

Create a new directory named wp in your C drive.

Move/copy the downloaded wp-cli.phar to the directory you just created.

Navigate to this directory using the command line and type the following command

php wp-cli.phar --info

If you see something like the following then WP-CLI is working fine. If not then you need to setup your environment variables. Make sure PHP path is available in the environment variables.

Download WordPress using WP-CLI

You can now access WP-CLI from any location using the command line

php "c:\wp\wp-cli.phar"

But this is way too much typing. We can access it easily by setting an alias to a batch file that invokes our command. To do this, create a new batch file called wp.bat in this same directory where you placed wp-cli.phar. Edit this batch file and paste the following commands

@echo off
php "%~dp0wp-cli.phar" %*

%~dp0 in that command is a variable that returns the path of the current batch script

Add the path to this directory to the environment variables using the following command

setx path "%path%;C:\wp"

You should now be able to access WP-CLI  using the alias wp. Try it out by typing the following command.

wp --info

WP-CLI info

Note: WP-CLI runs best on a UNIX-like environment like Mac or Linux. The tool has limited support in Windows.

Installing WordPress using WP-CLI

Now it’s time to install WordPress. We are using WAMP and all our projects reside in C:\wamp\www directory. Navigate to your project directory.

cd c:\wamp\www

Type the following command to create a new directory called wordpress

mkdir wordpress

Go inside this directory using the following command

cd wordpress

Let’s download a copy of WordPress using WP-CLI

wp core download

This will download the latest version of WordPress in the current working directory.

WP-CLI info

Next, we need to create a wp-config file for WordPress. Type the config command with the following options

  • –dbname is the name of the database
  • –dbuser is the database user
  • –dbpass is the database user password
wp core config --dbname=wp_cli --dbuser=wp_cli --dbpass=wp_cli

Change all of them to match your setup. You will get a  message that says Success: Generated wp-config.php file.

WordPress installed

The final step of installing WordPress is to create the database tables. For this we use the install command with the following options

  • –url The address of the new site.
  • –title The title of the new site.
  • –admin_user The name of the admin user.
  • –admin_password The password for the admin user.
  • –admin_email The email address for the admin user.
c:\wamp\www\wordpress>wp core install --url= --title="My WordPress Blog" --admin_user=the_admin --admin_password=the_password

WordPress installed

That’s all. You have successfully installed WordPress using WP-CLI.


Just like we said earlier, WP-CLI is a powerful tool which can do a lot of things. A full list of commands is available here. It’s well worth checking out.

We hope you found this useful. Leave your suggestions or feedback in the comments section below.

Play Basketball on Facebook Messenger

Next Article

Play Basketball on Facebook Messenger

Tapas Pal

Tapas pal is the founder of and he is an avid Internet geek enthusiast and writer has deep interest in technology, Digital Marketing and love tools that increase human productivity.