If you are a WordPress developer and you are not familiar with WP-CLI you can’t call you a professional. So today we are going to get acquainted with WP-CLI and WP-CLI WordPress installation.
WP-CLI is the tool which allows us to install WordPress, make backups, database import, export, working with plugins, making configurations and even working with posts and taxonomies with help of command-line.
You can know more about WP-CLI and it’s installation on the website https://wp-cli.org/
The only thing to add is that to install WP-CLI you need to download wp-cli.phar to rename it to wp without any extension to move to any place you want to set PATH to this place. Pretty easy.
WordPress installing with help of WP-CLI
I am using this way to install WordPress every time both on localhost and on a remote server.
Downloading the WordPress
When you are in the folder where you’d like to install WordPress just run the command:
wp core download
wp-config.php file configuration
wp core config --dbhost=localhost --dbname=db_name --dbuser=username --dbpass=password
Creating a database with WP-CLI
It’s really simple to remove, create, import, export database and to change old URLs to new ones with WP-CPI. To create a database you need wp-config.php file to have correct settings. After that type the following:
wp db create
WordPress core installation
wp core install --url=http://yourwebsite.com --title="Your Blog Title" --admin_name=wordpress_admin --admin_password=admin_password --email@example.com
Do not forget about setting correct permissions for WordPress folders and files:
chmod 644 wp-config.php chgrp web wp-content/uploads/ chmod 775 wp-content/uploads/
That’s all. This should be one the shortest and one of the most helpful articles about WordPress for you if you were not familiar with WP-CLI. Let us know your opinion, advice and so on. Thank you!
In addition, I’ll give you a recommendation to use also wp db export, wp db drop, wp db import, wp db search and wp search-replace commands as quickly as you can as they are really helpful and easy to use. See you soon!