Well, it’s that time of the year that I need to do a little spring cleaning of the ‘ole site. So I figured I’d post how to upgrade WordPress. It’s pretty straight forward. But before getting started back up your install. This includes the files and the database. First off, the files. For that just back up the root of your Apache home directory. If you’re on a shared host this is often the public_html or www folder. If you’re on a Mac Server this might be /Library/WebServer/Documents. If you’ve customized your css and themes, etc you will most certainly want to triple-check that you’ve gotten your wp-content folder.
Once you’ve got the flat files, it’s time to grab the database. Assuming you’re using MySQL, the following command will grab a snapshot of the database:
mysqldump -u admin -p ‘MYSUPERSECRETPASSWORD’ -h localhost wpkryptedblog > ~/kryptedbak.sql
In the above command you’re going to switch out the data following the data following the -u option with the username of your MySQL instance and the -p with the password (assuming your password isn’t MYSUPERSECRETPASSWORD as that might just be silly – which means I should probably change mine). Anyway, the data following the -h option is the server that MySQL is running on. In most cases the MySQL server will not be allowing traffic from any IP other than localhost and so you’ll likely need to run this on the host itself. In the case of a Mac or Linux box this is very easy provided you have a terminal to do so. In the case of many servers where you don’t have a command line they’ll likely give you a button in an application like CPanel to do all of what we’re doing here, thus you can skip this step. Anyway, following the address of the server is the name of the database. If you don’t know what the name of your database is then you’ll need to figure that out before moving on. Next, the greater than (>) in the command is telling the command to output everything in that database and write it to whatever file is indicated on the other side of the >. So we’re basically loggin into the MySQL daemon using mysqldump and writing the contents of the entire database into a file called (in this case) kryptedbak.sql that we can then use to load back into MySQL at a later date if/when we need to.
Now copy all the flat data files and MySQL databases to your machine, just to be safe. Now read through the rest of the instructions before taking any more steps to make sure that a) you qualify and b) you feel comfortable doing the upgrade. Now that we’re done backing everything up, let’s upgrade. First we’re going to grab the latest copy of WordPress. Do so by using this command:
wget http://wordpress.org/latest.zip -O latest.zip
There will now be a file called latest.zip in your previous working directory, likely your home folder (~). Now unzip it using this command:
unzip latest.zip
Now you’re ready to remove all the old crap from the older install that you no longer need. cd (changed directory) to the root of your WordPress folder/web root and run the following:
rm -rf wp-admin
Then run:
rm -rf wp-includes
Now copy the new stuff in there (don’t cd out of that directory btw – or if you do change the . in the following command to the path of that folder):
cp -avr ~/wordpress/* .
Now for the moment of truth, open a web browser and go to:
http://yourdomain.com/wp-admin/upgrade.php
Obviously, change the yourdomain.com in the above command to whatever your domain or IP address happens to be. At this point, you’ll be looking at the WordPress upgrade page and believe it or not, WordPress will be happy to do all the heavy lifting for you. When it’s done, log into your administration panel and if your admin icons are all on the left hand side of the screen then your upgrade is a success. Now open your site and make sure that the theme is compatible with 2.7. If so you’re good. However, all of your plug-ins will be disabled. So one-by-one go through and re-enable/activate them. Once activated test your page and verify that things load up properly. If one doesn’t work check out the forum for that plug-in and make sure it’s compatible (not all are). Once you’re done, you’re done.
Now, in some cases (especially with apps like c-panel, which would use Fantastico for the entire process), you’ll likely want to do all of this through your portal. If you aren’t sure, check with your web host prior to doing any of this. Also, if you have a mission critical site, I’d recommend doing this in a sandbox before going live with it. That way you can test everything. The MySQL dump will be just as good as a production database in that case and you’ll be able to test all your extensions to WordPress prior to attempting to go live.