Member preview

Create a Wordpress site from the command line with wp-cli

The first step is to install the wordpress command line tool. The below commands will download the package, grant the appropriate permissions for using the files and move the package to a place in our computer to a place where we can conveniently use it.

tl;dr — source code

$ curl -O
$ chmod +x wp-cli.phar
$ sudo mv wp-cli.phar /usr/local/bin/wp
$ wp

After running these commands on your Mac or Unix-like system you should have the ability to use wp from the command line.

Next create an empty project directory and download the Wordpress core codebase.

$ mkdir wordpress-local-site && cd wordpress-local-site
$ wp core download

By default this will generate a site for english, US (en_US). If you live in a different part of the world you can specify a locale (code list) by appending --locale=YOUR_COUNTRY_CODE.

Next we can start the server and begin the famous five minute install by running:

$ wp server

This will start a PHP server and run the website we just downloaded on http://localhost:8080 in your browser. Next up we’ll have to let our brand new site know about the database that we’d like it to talk to.

In the installation process you will encounter this screen:

Wordpress database connection page, running locally at localhost:8080

You’ll need to know the username and password for the MySQL database on your machine. If you do not have MySQL installed you can follow this tutorial.

Create the database using the below command or a GUI like Sequel Pro.

$ mysql -uroot -p
> create database wordpress;

From there you’re running a Wordpress site locally on your computer! Feel free to interact with the GUI to add and update data.

A wordpress site running locally at localhost:8080
Twenty seventeen: the default wordpress theme that comes with every installation

Further resources:

🚀 Create a free profile on to browse tech companies in San Francisco