How to manually update WordPress installation on a LEMP stack on Ubuntu

WordPress constantly evolves to give website owners more features and security improvements to make their website great. After getting over with months of procrastination on updating my WordPress installation, I had finally get my act together to proceed with updating my WordPress installation.

As I do not like to give my PHP-FPM and Nginx write access to the directory that contains my WordPress installation, I had decided to update my WordPress installation manually.

I document the steps that I had went through to manually update my WordPress installation on my LEMP stack on Ubuntu in this post for future references.

Backing up our WordPress database

Unless we have a cron job that helps us backup our WordPress database, it is advisable to backup our WordPress database before proceeding with the manual update of our WordPress installation. To backup our WordPress database, we can run the following command in our shell program:

mysqldump -u db_username -p database_name > /location/to/backup/database_name_YYYYMMDD.sql

This will create a sql script that we can use if we need to revert the changes that WordPress does to our database during the update process.

Deactivating all our plugins

After making sure that we have a backup of our WordPress database to guard against any catastrophe, we can then proceed to deactivate our plugins. To deactivate all our plugins:

  • access our WordPress admin Dashboard with a web browser,
  • go to Plugins -> Installed Plugins,
  • check the checkbox beside Plugin,
  • choose 'Deactivate' from the 'Bulk Actions' combobox, and
  • click 'Apply' next to the 'Bulk Actions' combobox

Getting the latest copy of WordPress

After deactivating all our plugins, the next step is to download the latest copy of WordPress. To minimize bandwidth costs and download time, it is better to download the latest copy of WordPress from within our Ubuntu server. To download the latest copy of WordPress, we can run the following commands in our shell:

cd ~/an/empty/folder
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz

With the above commands, we first get the shell into an empty folder inside of the home directory. We then download a .tar.gz file that contains the latest WordPress codes. After the download had completed, we then extract the wordpress folder from the .tar.gz file. With that, we will have the latest WordPress codes at ~/an/empty/folder/wordpress.

Porting over the customized codebase from our old WordPress to the latest one

Once we have the latest copy of WordPress in ~/an/empty/folder/wordpress, we can copy the customized codes into the new WordPress folder. Assuming that our existing WordPress folder is located at /mywebsite, we can run the following commands in our shell to port the customized codes from the existing WordPress folder to the new WordPress folder:

sudo cp /mywebsite/wordpress/wp-config.php ~/an/empty/folder/wordpress/wp-config.php
sudo cp -R /mywebsite/wordpress/wp-content/ ~/an/empty/folder/wordpress

With the above commands, we move our wp-config.php and everything in our wp-content folder from the existing WordPress installation folder to the new WordPress folder.

Making the shift from old to new

Once we had moved our customized codes to the new WordPress folder, it is time to make the shift from old to new. To do so, we run the following command in our shell:

sudo mv /mywebsite/wordpress /mywebsite/wordpress-old
sudo mv ~/an/empty/folder/wordpress /mywebsite/wordpress

With the above commands, we first rename the existing WordPress folder to wordpress-old. We then move the new wordpress folder to the same location where the old WordPress had resided at.

Restarting PHP-FPM

Once we had made the shift from old to new, we can restart our PHP-FPM.

To restart the PHP-FPM process for PHP 5 in Ubuntu 14 and earlier, we can run the following command in our shell:

sudo service php5-fpm restart

To restart the PHP-FPM process for PHP 5 in Ubuntu 15 and later, we can run the following command in our shell:

sudo systemctl restart php5-fpm.service

Triggering the new WordPress codes to update the database

After our PHP-FPM process restarted, the new WordPress codes will be used to process subsequent HTTP requests to our WordPress website. The last step to the manual update of our WordPress website is to get the new WordPress codes to update the database. To trigger the new WordPress codes to update the database, we access our WordPress admin page with our web browser and click on the button that appears.

Advertisements

About Clivant

Clivant a.k.a Chai Heng enjoys composing software and building systems to serve people. He owns techcoil.com and hopes that whatever he had written and built so far had benefited people.

Advertisements
Advertisements