WordPress Manual Upgrade for Experts

Revision as of 23:55, 29 January 2020 by Root (talk | contribs) (Upgrade)

There are lots of websites detailing how to manually upgrade a WordPress Site. Most of them seem to be done by people with very little background in Linux or command line usage (no offense to them). But there is a simpler way if you know some advanced techniques.

Why upgrade manually? For me it was not wanting to upgrade to a 5.X.Y version and instead stay with the latest 4.X.Y version because of a lot of customization based on the 4 series.


BACKUP!

First of all BACK EVERYTHING UP!!! Don't take a chance that the upgrade will mess something up, make a backup. For WordPress, that consists of two items: The website files and the data base.

Website Files

Backup the website files (actually make a copy)

mv WebSiteDirectory WebSiteDirectory.WorkingVersionX.Y.Z

...The original files will then be used to copy into the directory with the upgrade version, covered a few steps later.

The above is the quickest way to preserve a functional version of the website files (the MV command does not change permissions) also test as you go. The next step isn't necessary, but if you want to make a test copy of the website files for peace of mind use the below command;

cp -ax WebSiteDirectory.WorkingVersion.X.Y.Z WebSiteDirectory

The WebSiteDirectory will need to be erased before copying the new updated WordPress files.

Now test the web site. It should be completely functional as the above command copies all files and directories (sub too), retains permissions, retains symbolic links, IE makes an exact duplicate.

Database

For the database, use the command line or phpMyAdmin. phpMyAdmin makes it really easy. Select the database, export, simple, Go, save it, done.

Other Thoughts

Most of the people that have documented how to do a manual upgrade of WordPress also stress the importance of backing up. Their methods won't work if the WordPress upgrade hoses the site for some reason. IE, if one uses a plugin to backup a WordPress site, an upgrade is done which hoses the site, how does one restore a backup with a plugin if the site doesn't work? Bit of an issue there, so instead why not get down to basics and uses some basic commands as explained here. The bottom line is that if one is doing some major stuff like an upgrade, don't rely on a plugin to restore things.

Upgrade

  • Download whichever version of WordPress you want: https://wordpress.org/download/releases/
  • Extract the files (if downloading a TAR version): tar -xf WhatEverFIleName
  • Move or copy the files to the web server directory: mv Source Destination
  • Set the proper ownership and file permissions on the new files (the below example is for CentOS and Apache);
    chown -R apache:apache /var/www/html/WhatEverDirectory
    find /var/www/html/WebSiteDirectory -type d -exec chmod 755 {} \;                      
    find /var/www/html/WebSiteDirectory -type f -exec chmod 644 {} \;
  • Copy the working version of the WordPress website files into the new directory (The below command will not overwrite any of the new files and will also preserve all permissions from the "working" WordPress files. The end result is upgraded WordPress Files and any custom stuff in the same directory);
    cp -R -T -n -v -a -x /var/www/html/WebSiteDirectory.WorkingVersion/* /var/www/html/WebSiteDirectory 
    
    Don't forget the ASTERISK on the end of the Source.
    Flags can be combined, IE -Rnvax, but are shown separately for clarity.
  • Make sure the wp-config.php file is in the upgrade directory (there shouldn't be a wp-config.php file in the upgrade folder and it should be copied with the above CP command)
  • Also remember a LOT of extensions use the .htaccess file to modify the behavior of WordPress, so make sure that file from the original version of that file into the upgrade directory (its a hidden file, so make sure).