Upgrade WordPress via SSH on Ubuntu 16.04 LTS

Sometimes, folder permission restrictions prevent webmasters from updating WordPress from within its dashboard… If you cannot update or upgrade WordPress from its dashboard, then you might want to do it via SSH terminal console…

When WordPress content in a directory that’s restricted, every time you wish to install or delete plugins and themes you’ll get an error…

If you can’t resolve the issues by re-adjusting the directory permissions, you may have to update / upgrade WordPress via the command line. This brief tutorial is going to show you how to do it easily.

When you’re ready to update or upgrade WordPress via SSH terminal, continue below:

Step 1: Backup WordPress database

Before making changes to your WordPress site it’s recommended that you always backup your database content. To do that, run the commands below

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

Replacing wp_databaseName with your database name.. that should create a backup of the database.. or you may want to use a backup plugins for WordPress… There are many in the plugin store.

Step 2: Backup WordPress content

You may also want to backup WordPress content. Use Rsync to copy WordPress content directory to a backup location. To do that, run the commands below.

sudo rsync -Waq /var/www/html/wp_content  /path/to/backup/directory/

After backing up WordPress database and content, continue below to begin upgrading WordPress.

Step 3: Delete WordPress wp-includes and wp-admin directories

To begin upgrading, delete the existing wp-admin and wp-include directories.

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

After deleting WordPress existing folders for wp-admin and wp-includes continue to downloading WordPress content.

Step 4: Download the latest WordPress content

Next, use the link below to download WordPress latest content online

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

Unzip the content

unzip latest.zip

Step 5: Move WordPress latest content to the root directory

Finally, run the commands below to copy WordPress latest content to the root directory

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

After moving the newest content to the root directory, open your browser and browse to your host to run W0rdPress upgrade script.

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

The link above is use to upgrade WordPress and its database. It may take a few seconds for this process to complete, after which, your systems should be upgraded and ready to use.

This is how to Upgrade WordPress via SSH command line.

Enjoy!

You may also like the post below:

Setup Ubuntu 16.04 LTS with Apache2 2.4.29, MariaDB 10.2, PHP 7.2 (LAMP)

2 Replies to “Upgrade WordPress via SSH on Ubuntu 16.04 LTS

  1. In Step 1 you mean to use MySqlDUMP. Not sudo mysql -u root -p wp_databaseName > wp_databaseName.sql but sudo mysqldump -u root -p wp_databaseName > wp_databaseName.sql

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.