Updating WordPress version on the cloud server instance

To manually update WordPress (WP), we must find out the location of the web root folder where WP is served from. There are many ways WP can be hosted and therefore the location of the web root folder on the cloud instance can vary.

This example covers WordPress on Linux-Nginx-MySql-PHP (LNMP) stack hosted on an Elastic Compute Service instance (ECS) on Alibaba Cloud. The web root folder is located at:

Remote into ECS instance

Remote into your Alibaba Cloud Linux server instance, you can either use the build in the web console or use a third party tool that supports Secure Shell (SSH) such as Putty.exe.

However before SSH can be used to remote into your server instance, you must ensure that the Alibaba’s Security Group (SG) allows SSH traffic to your server instance. Modify the SG of your instance to allow port 22 traffic. You will need the public IP of your server instance and the root username and password for initial login.

Below is an image of what the SG might look like:

Example SG setup with SSH traffic enabled for a specific server instance.
Navigate to the home directory and remove old WP versions

Navigate to the home directory and list the contents after you have connected to your instance. Assuming you have an out-of-box WP image from Alibaba’s market place, you will see the “old” WP files used for the current WP installation. Delete these installation files and pull the latest WP installation files from the web.

Below is a script that does the following:
– List the content of the home directory
– Removes old WP installation files and folders
– Retrieve latest WP installation
– Extract latest WP installation files into a “wordpress” directory

# Lists content in the home directory
cd ~ ; ls
# Deletes the file and directory (contains extracted WP files)
rm latest.tar.gz ; rm -rf ~/wordpress;
# Get latest WP installation file
wget http://wordpress.org/latest.tar.gz
# Unzip the latest WP installation file
tar xzvf latest.tar.gz
Stop Nginx and replace WP files with newer version

The next step is to locate the web root of Nginx and replace the current WP files with the newer WP files.
Use the below commands to:
– Stop Nginx server
– Replace WP files with the newer (extracted) WP installation files
– Startup Nginx server.

# Stop Nginx server
sudo service nginx stop
# Copy the extracted WP installation files to the Nginx web root
sudo cp -r ~/wordpress/* ~/../data/wwwroot/default/
# Check the files 
ls -l ~/../data/wwwroot/default/
# Start up Nginx server
sudo service nginx start

Leave a Reply

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