A Lazy Developer’s Guide to Managing WordPress Updates
WordPress is one of the most popular Content Management Systems, used for blogs and websites among other things. It has thousands of plugins, including Embed-Iframe maintained by me, to extend the platform functionality. This also makes it the target of many security attacks. An effective mitigation practice against security attacks is to keep WordPress updated with the latest releases.
We can update WordPress by
- Providing FTP information in WordPress dashboard,
- Specifying FTP credentials in
wp-config.php
, - Downloading WordPress release and updating manually,
- Using Subversion releases, or
- Configuring Direct File I/O method in
wp-config.php
define('FS_METHOD','direct');
The method we are going to follow is using WP-CLI — Command Line Interface for WordPress.
Installing WP-CLI
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
To map wp
command in Console
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
Let’s check if it is working
wp --info
Installing WordPress
If we don’t have WordPress installed already, we can run the following command to install the latest version of WordPress in the current folder
wp core download
Since it is the first time installation, we need to configure the database access. So, first let’s connect to the database and create an empty database
mysql> create database <Database Name>
Configure WordPress to use this database
wp config create --dbname=<Database Name> --dbuser=<Database User> --dbpass=<Database Password>
and then navigate to the WordPress installation homepage in the browser and complete the set up.
and then navigate to the WordPress installation homepage in the browser and complete the set up.
Updating WordPress
- Updating current branch:
wp core update
- Updating to a specific version:
wp core update --version=<Version #>
- Updating to the latest nightly builds:
wp core update --version=nightly
- Updating to the `trunk`:
wp core update --version=trunk
Maintaining Plugins
- Installing a plugin:
wp plugin install embed-iframe
- Activating
wp plugin activate embed-iframe
- Updating:
wp plugin update embed-iframe
Updating WP-CLI
We can update WP-CLI at any time by running
wp cli update