Site icon WPDig.com

How to update WordPress from the command terminal

This post shows students and new users the steps to update WordPress through the SSH terminal console. When you are running a WordPress website, one task that you will have to learn quickly is updating or updating your WordPress content.

If you are lucky, you may have a WordPress website that updates automatically when new versions are released. If that’s the case, then you should be good to go. Nothing to do but sit back and relax.

However, not all WordPress websites are set to update automatically when new versions are released. If your WordPress site is set where it cannot be automatically updated, you may need to update from the server console or use other means.

An easy way to update WordPress content is from the server terminal. The server can be accessed via SSH or directly. Once in the terminal console, you should be able to update WordPress with ease.

When you are ready to update or update WordPress via SSH terminal, continue below:

How to backup WordPress database

Before making changes to your WordPress site, it is recommended that you always backup your database content. If you are running a MySQL or MariaDB database server, the following commands show how to back up a database.

sudo mysqldump -u root -p wp_database > wp_database.sql

Replace wp_database with your WordPress database that you want to back up. If you have a plugin that can backup WordPress content, use it to backup WordPress before proceeding below.

How to backup WordPress content

You may also want to backup WordPress content. Assuming WordPress is installed on the / var / www / wordpress, use rsync to copy the WordPress content directory to a backup location.

To do that, run the following commands.

sudo rsync -Waq /var/www/wordpress  /path/to/backup/directory/

After backing up your WordPress database and content, continue below to start updating WordPress.

Remove the wp-includes and wp-admin folders from WordPress

To start updating, remove the wp-admin and wp-include directories.

sudo rm -rf /var/www/wordpress/wp-includes
sudo rm -rf /var/www/wordpress/wp-admin

After deleting existing WordPress folders to wp-admin and wp-include folders, go and download the updated WordPress content.

How to download WordPress content

To download the latest WordPress content, simply run the following commands. Once the content is downloaded, the following command extracts it.

cd /tmp/ && wget https://wordpress.org/latest.zip

Unzip the contents of the download using the following commands.

unzip latest.zip

Replace WordPress content with the latest one

Finally, run the following commands to copy the latest WordPress content to the root directory. Doing this will replace the wp-include and wp-admin folders and overwrite any other folders with newer versions.

sudo mv /tmp/wordpress/* /var/www/wordpress

After copying the files, open your browser and find the WordPress URL of the site to start the update.

http://www.example.com/wp-admin/upgrade.php

Replace www.example.com in the url with your own domain.

After a short moment, your WordPress site should update with the latest files. You can then log in to see the changes.

That is all!

Conclusion:

In this tutorial we have seen how to update WordPress. If you find any errors above or have something to add, please use the comment form below.

Exit mobile version