Using WP-CLI to Install WordPress

My web server is running Ubuntu 15.10, so these instructions apply to this version of Linux. YMMV.

WP-CLI is a sweet, command-line tool for managing WordPress installations. First things first, we need to install it. Best thing to do is follow the instructions on the site I just linked.

Next step is to get an empty MySQL or MariaDB database ready, preferably with a unique, restricted user attached to it. See the bottom of this post if you're not sure how to do that.

Next, create a directory for WordPress to be installed in. How you set up your files is up to you. Once it's ready, open a terminal and navigate to the directory you created.

Download the latest stable version of WordPress into the working directory:

wp core download

Next, create your wp-config.php file (replace the items in angle brackets as applicable):

wp core config --dbname=<DATABASE_NAME> --dbuser=<USER_NAME> --dbpass=<PASSWORD>

Finally, install WordPress and set up the admin user:

wp core install --url=http://<YOUR_URL> --title='<SITE TITLE>' --admin_user=<ADMIN_USER_NAME> --admin_email=<ADMIN_USER_EMAIL> --admin_password=<ADMIN_PASSWORD>

That's it! Browse to your URL and (assuming your server is correctly configured), you should see your brand new WordPress installation.

Also, just in case command-line MySQL scares you, here are the commands to create a new database with its own user:

mysql -u root -p
CREATE DATABASE <DATABASE_NAME>;
CREATE USER '<USER_NAME>'@'localhost' IDENTIFIED BY '<PASSWORD>';
GRANT ALL PRIVILEGES ON <DATABASE_NAME>.* TO '<USER_NAME>'@'localhost';
FLUSH PRIVILEGES;
exit;