How to upgrade Wordpress? Best and safest way to upgrade

Upgrading wordpress can be a bit of a hassle especially if you are doing so using the wp-admin section. Here is the list of possible issues you may encounter during the core upgrade and quick ways to resolve these issues:

  • Wordpress is asking you for your ftp credentials during the update process
    It may be possible that the process running your web application is unable to write to the files . This can be either apache2, nginx or php-fpm. The issue can be resolved by granting write access to the user running your web server application.
  • Message appears: another upgrade is in progress - but upgrade was not accomplished
    This clearly indicates that the upgrade attempt was not successful. In order to retry the upgrade, you have to unlock the system. This can be done using the query:

    delete from wp_options where option_name="core_updater.lock";
  • Wordpress is stuck on "Site is under maintenance".
    When doing upgrade, system will be switched to maintenance mode. This will be identified by adding a ".maintenance" file in your project root. If you are sure that the maintenance did not succeed and want to continue running your wordpress application, this can be done, by removing the ".maintenance" file, located in your project look.

The easiest and most preferable way to perform an update would be by having shell access to your host.  I would recommend downloading the latest version of the wordpress. After this wordpress files should be extracted to substitute the existing files and update.php script should be executed from your domain name. Do not forget to backup your existing code and database before the upgrade!

Follow the instructions below to upgrade your wordpress:

  1. Backup your existing files and database:
    mkdir /tmp/backup
    cd /tmp/backup
    

    tar czf backup.tgz /var/www/[your site directory] mysqldump -uroot -p [database name] > database.sql

  2. Download and extract the contents of the latest wordpress code
    cd /tmp
    wget http://wordpress.org/latest.zip
    unzip latest.zip
    

    cd /var/www/[your site directory] cp -avr /tmp/wordpress/* . rm -rf /tmp/wordpress /tmp/latest.zip

  3. Run the upgrade script:
    http://[your wordpress site]/wp-admin/upgrade.php

If something goes wrong, you can always locate your backup files in /tmp/backup , extract them , recover the database dump and go back to the previous state.

During the migration process and for other cases of wordpress troubleshooting it may be useful to turn on debugging. This can be achieved by switching these parameters in wp-config.php file:

// turns on debugging, output is displayed on the web page
define('WP_DEBUG', true);

// the debug log will be saved to wp-content/debug.log define( ‘WP_DEBUG_LOG’, false);

Hope this helps :) enjoy migrating your wordpress site successfully !