Don’t you think that the “famous” 5-minute WordPress installation is still taking too much of your time? If you are interested in quicker and smarter ways to automatically install and manage WordPress, together with a given set of plugins and your themes of choice, please read on.
Some years ago, you could have given WordPress quick install a try, but that is now an abandoned project, probably not supporting the latest version of WordPress.
The coolest way of doing WordPress today is via the WP-CLI and some scripting in your favorite language.
Let’s download WP-CLI with:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
then verify the Phar file is working:
php wp-cli.phar --info
To use WP-CLI from the command line by typing wp
, we need to make the .phar file executable and move it to somewhere in our PATH. For example:
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Final installation check:
wp --info
For getting help, let’s type:
wp help
Let’s download and install a WordPress site in seconds:
mkdir mywpfolder; cd mywpdfolder
# Download WordPress core
$ wp core download --locale=it_IT
Downloading WordPress 5.3 (it_IT)...
md5 hash verified: c5366d05b521831dd0b29dfc386e56a5
Success: WordPress downloaded.
# DB configuration
# (define a database, username and password to be used in the next step), e.g. with MySQL:mysql -u user -p
create database wordpress
;grant all on wordpress.* to 'user' identified by 'password';
quit;
# Create a wp-config.php file
wp core config --dbname=wordpress --dbuser=user --dbpass=password --dbhost=localhost --dbprefix=wp_
# Install WordPress
$ wp core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword --admin_email=info@example.com
Success: WordPress installed successfully.
# Display the WordPress version
$ wp core version
5.3
If you have many WordPress installation on your server, there’s a ‘find’ command that comes in handy. Let’s install the corresponding package as follows:
wp package install wp-cli/find-command
Now we are ready to find all the WordPress installations on the server, starting from a given path:
wp find .
Let’s update a WordPress installation in a breeze:
sudo -u myuser -i wp core update --path=path/to/my/wordpress/installation
sudo -u myuser -i wp core update-db --path=path/to/my/wordpress/installation
What about listing and updating the plugins too?
sudo -u myuser -i wp plugin list
sudo -u myuser -i wp plugin update --all
Fancy clearing cache now?
sudo -u myuser -i wp cache flush --path=path/to/my/wordpress/installation
Enjoy Dev-Ops for WordPress!