Keeping your WordPress installation, plugins and themes up to date is very important. You have to continually update WordPress immediately after a new version is released. The new versions will bring you new features, bug fixes, stability improvements and the most important – security fixes. If you do not update your WordPress website it is very likely that your website will be hacked at some point. In this case you can lose your website content, your customers, lose your Google ranking, your website can be defaced, your server can be used for spamming, and many more. So, updating WordPress should be on the top of your list when it comes to the security of your Linux virtual server.
In this blog post we will explain how to update your WordPress installation to the latest available version through the Linux command line.
Log in to your server via SSH as user root and first of all make sure to create a backup of your website and database.
Create a backup of your MySQL database.
mysqldump -u DBUSER -p DBNAME > /root/database_dump.sql
Replace DBUSER with your actual MySQL user and DBNAME with the name of the WordPress database. Once you execute the command you will be prompted to enter the password of the database
Now, backup the website files using the following command
rsync -Waq /path/to/your/site /path/to/backup
Don’t forget to replace the paths in the command with the actual paths.
Now, once we have created a backup of the website files and the database, we can start the update. If something goes wrong, you can easily restore your WordPress website from the backup.
Change the current working directory to the document root directory and download WordPress zip archive from their official website
cd /var/www/html wget https://wordpress.org/latest.zip
Unpack the zip archive
This will create new ‘wordpress’ directory
Remove the ‘wp-admin’ and ‘wp-includes’ directories from your old WordPress installation
rm -rf oldwordpress/wp-includes rm -rf oldwordpress/wp-admin
Replace ‘oldwordpress’ with the actual name of your WordPress directory.
Now, move all content of the newly created ‘wordpress’ directory to the old WordPress directory and overwrite all files and directories.
mv wordpress/* oldwordpress/
Delete the zip archive and the empty ‘wordpress’ directory
rm -rf wordpress rm -f latest.zip
With this step the WordPress upgrade process from the command line is completed. Now you need to access http://yourdomain.com/wp-admin/upgrade.php to run the upgrade script and upgrade the database.
WordPress can be also upgraded through the command line interface using the WP-CLI interface. It is already explained in one of our previous blog posts.
- How to install Joomla 3 on Ubuntu 14.04
- How to backup a WordPress website to remote cloud storage from the Linux command line
- How to Install Dotclear on a Debian 8 VPS
- How to Install PunBB on a Debian 8 VPS
- How to Install Trident on an Ubuntu 14.04 VPS
- How to install CS-Cart v4 on an Ubuntu 14.04 VPS
- How to Install and Configure MySQL Cluster on CentOS 7
- How to install e107 CMS on Ubuntu 14.04
- Install miniBB forum on CentOS 7
- How to install Pimcore on Ubuntu