WordPress Quick Upgrade for Linux
Never ever upgrade WordPress to the latest version as soon as it comes out, unless you want to be the guinea pig dealing with the new bugs and incompatible plugins. Even if the new version of WordPress contains critical security updates, wait a couple of weeks to let others work out fixes for any new bugs and to let the plugin authors ensure compatibility.
You always need to have a test version of your WordPress site. Duplicate your database with a different name and duplicate your WordPress installation in a separate folder on the server. This will be your sandbox for testing new versions of WordPress and plugins. If the new version breaks something, it will not be your production site.
It is always a good idea to first test the upgrade on a copy of your site. To create a copy, follow these simple steps:
INSTALL_DIR=/srv/www/htdocs/wordpress TEST_DIR=/srv/www/htdocs/wordpress_test mkdir ${TEST_DIR} rsync -avu ${INSTALL_DIR}/ ${TEST_DIR}/ |
Now you will need to connect to MySQL and create a copy of your database. This is best done from command line:
mysql -u<USERNAME> -p<PASSWORD> CREATE DATABASE wordpress_test; quit |
Now you can use the mysqldump command to copy structure and contents from your primary database to the “wordpress_test” database you just created:
mysqldump -u<USERNAME> -p<PASSWORD wordpress | mysql -u<USERNAME> -p<PASSWORD> wordpress_test |
Use MySQL to grant your database user account necessary permissions to access the new database.
Now you need to modify $TEST_DIR/wp-config.php to change the following line to name of the new database:
define('DB_NAME', 'wordpress_test'); // The name of the database |
Below is the basic upgrade procedure for WordPress running on a Linux/Unix server. This process assumes that all custom content of your WordPress installation is limited to the “wp-content” directory. Even so, the first step of any upgrade process is to backup existing files and configurations. In the following example we assume that the path to your WordPress installation is “/srv/www/htdocs/wordpress”, the path to your backup directory is “/var/backups”, and the main URL of your WordPress site is “http://www.mydomain.com”. So here we go:
- Place your site in maintenance mode, so users can’t login and change any content.
- Download and install the WP-DBManager plugin. Activate the plugin.
- In the wp-admin interface click on “Database” -> “Backup DB” -> make sure all the settings are correct -> enable GZIP compression -> click “Backup”. This will backup your WordPress database and give you something to fall back on in case your upgrade fails.
- Run the following commands to download, unpack and install the new version of WordPress:
#!/bin/bash INSTALL_DIR=/srv/www/htdocs/wordpress BACKUP_DIR=/var/backups cd $INSTALL_DIR tar cvf ${BACKUP_DIR}/site_backup_`date +'%Y-%m-%d'`.tar . gzip ${BACKUP_DIR}/site_backup_`date +'%Y-%m-%d'`.tar wget http://wordpress.org/latest.tar.gz tar xfz latest.tar.gz rm -rf ./wp-includes/ rm -rf ./wp-admin/ cd ./wordpress cp -rpf --reply=yes * ../ cd .. rm -rf ./wordpress/ rm -f latest.tar.gz |
In the browser, go to http://www.mydomain.com/wp-admin/upgrade.php and upgrade the database. And that’s all there is to upgrading your basic WordPress installation.
Popularity: 4% [?]
Related posts:



As if to confirm the above warning to never rush with upgrading your WordPress to the latest and greatest release, version 2.6 just came out with a major bug. Basically, once you upgrade from 2.x to 2.6, you will not longer be able to login to the WordPress admin interface. Yeah, that may be inconvenient. There is a quick fix, though. Add the following line to your wp-config.php
@define(‘ADMIN_COOKIE_PATH’, ‘/wp-admin’);
This should provide you with a workaround until the WordPress team releases an official fix.
[Reply]
[...] my own advice to never install latest WordPress releases as soon as they come out, I upgraded my installation to [...]