WordPress is very easy to install and aside from the very quick manual installation method there are several other ways e.g. One-click installers provided by hosting companies and the installers from cpanel. My preferred way of installing wordpress If I have digitalocean, AWS, Google cloud or similar servers is through the WP-CLI.
WP-CLI is a command-line interface tool for WordPress that supports all WordPress versions and enables automation, quicker and more effective jobs, reproducibility, scripting, and other features. Anyone who frequently works with WordPress should understand know how to utilize this useful tool because it can save a lot of time.
Installing WP-CLI
Requirements for installing WP-CLI.
- Unix-like systems, including Linux or wsl for windows machines
- WP-CLI minimally requires PHP 5.4.0 or later. PHP 7.2 or later is recommended
- PHP Extensions enabled curl, mbstring, openssl, PDO, Phar, simpleXML, tokenizer
- WP-CLI is a a command-line tool so shell access or terminal are needed to run the commands
- MySQL/MariaDB as it is needed by WordPress.
Run the following line in your terminal to install WP-CLI:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
make the file executable with the following command:
chmod +x wp-cli.phar
move the file to the /usr/local/bin directory so that you can run it from anywhere:
sudo mv wp-cli.phar /usr/local/bin/wp
To verify that WP-CLI is installed correctly, run the following command:
wp --info
You should see the WP-CLI version and system information displayed on the terminal.
Installing WordPress
First navigate to the directory where you wan to install your wordpress files (you can move the files if you need to as well) and run the following command on your terminal.
wp core download
Create a config file for your site by entering the following command on the terminal
wp config create --dbname=DBNAME --dbuser=DBUSER --dbpass=DBPASSWORD
If successful, the prompt will show the following
Success: Generated ‘wp-config.php’ file.
replace the DBNAME, DBUSER AND DBPASSWORD accordingly.
have the WP-CLI create the database using the config file you just created by the following command
wp db create
If successful, your terminal will display the following
Success: Database created.
Lastly, installation of wordpress
wp core install --url=http://YOURURL --title=YOURTITLE --admin_user=ADMINUSER --admin_password=ADMINPASSWORD --admin_email=ADMINEMAIL
replace the http://YOURURL, YOURTITLE, ADMINUSER, ADMINPASSWORD and ADMINEMAIL accordingly.
Verify that WordPress is successfully installed correctly by opening your web browser and navigate to http://YOURURL and you could login to the dashboard by entering ADMINUSER and ADMINPASSWORD on http://YOURURL/wp-admin
for more information on how to use WP-CLI visit https://wp-cli.org/