Once in a while you must do this and, if you end up lazy for years like me, may even feel nightmares about upgrading from version 2.x to version 4.x, luckily upgrading WordPress is one of the easiest things you can do:
Making a backup
It’s always wise to backup your site before you make such a change. Don’t worry, you don’t need to backup absolutely everything, but check which things you need to backup depending on your needs:
1. Your posts and comments:
which is as easy as going to admin > Tools > Export and save an XML (maybe JSON in future?) file with all the relevant content. Whatever happens now, any wordpress version should be able to recover your most relevant data.
2. Your wp-content:
usually you don’t need to save this even when upgrading, but if you are making a huge upgrade you probably want to save whatever is inside your wp-content like themes, uploads and plugins, so that you can continue using them (unless they aren’t compatible with the new version). Alternatively just write down which plugins/themes you were using so you can find them back and install them later if something goes wrong. Though if you had images/files on the uploads they won’t be there anymore, be warned.
3. Your config.php file at the root of the blog:
which is the file that contains the details to connect to the database, you can generate it again later but why the hassle when you already have it. Just save it and paste it back later if needed.
4. Your .htaccess file at the root of the blog:
which is the file used for pretty permalinks.
5. All the files:
Ok, only in case of a mega-upgrade like going from 2.x to 4.x you want to take this many precautions. Sometimes it’s easier to just connect through FTP and say -> download it all, and that’s it. But downloading ALL takes more time than downloading just the themes, plugins and the config.php.
6. Backup the database:
having the exported file with your posts and comments should be enough, but it’s also true that other plugin and general settings or users would be lost. If you are worried of losing such data (like SEO/rewrite configs that could change all the urls and fuck it up hugely) then make a database backup. I didn’t and it was ok for me, but I’m that lazy and it’s a personal blog so who cares.
Upgrading using the Admin Panel
Ok so from version 2.7 or so WordPress can auto-upgrade itself by just getting into the admin panel and clicking a button. To do this you need writing permissions on your server side to the appropriate users but if you do, this is the easiest way to upgrade.
Done.
Setting server permissions
On my case: Plesk -> File Manager -> Add permissions to user “User IIS”, make sure you check the “add to child folders and files” option.
Personal note: Mi blog en rubencanton.com está en un folder hecho por mi y pude meterle los permisos, en cambio entrecodigos.com está sobre el root y no puedo dárselos, así que es posible que no pueda hacer upgrades automáticos.
Upgrading manually
In case you don’t have those permissions set up or your upgrade is massive and you don’t think it will handle it, follow these steps:
1. Download newest wordpress version
Just get to wordpress.org and download the latest version.
2. Backup all your files and content
As explained above, I didn’t back up the database but hey… just a personal blog so it’s fine.
3. Remove files
As you are on it already connected via FTP, just remove everything.
4. Add new files
Upload the new version of wordpress files. Once done, remember to include the config.php you saved on backing up and remove the config-sample.php. You can also add the stuff inside wp-content now, but it’s wiser to always go step by step to check everything is ok.
5. Connecting to DB
If you saved your config.php and added it back you shouldn’t need to do this, if not, prepare to set up the db connections. WordPress will need writing permissions to do this so be ready to grant those on your server-side as explained on (updating using the admin panel).
Upgrade the database
You need to run WordPress’s task to make required upgrades on the database, just get into wp-admin/upgrade.php as admin and click the Run button.
It did seem to have an error when I did it, probably due to how massive my upgrade was, but made the changes nonetheless so if I refreshed the u`pgrade.php page it displayed the “It’s already updated” message.
Get into the admin and set up things again
If you didn’t upload the theme this is a good moment to do so, or to change to a newer and responsive one. In any case, old theme is selected so if it’s not included the blog will be empty until you select an existing one or upload the old one.
Same goes for plugins, if you want to re-activate them make sure you have them back. Also, if you gave permissions to your server user to modify files you can upgrade your plugins with one click now.
Other possible issues
Check if you had other folders or files on the backup like a robots.txt or some other custom folder, I had some “imagenes” folder where I had uploaded some images instead of using wordpress’s uploader.
Permalinks
On upgrading from WordPress 2.x to 4.x the pretty permalinks stopped working. I forgot to add the .htaccess file and also to use a new format for it:
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Once that’s done, give WordPress permissionss to write that file and go back to admin -> settings -> permalinks to use my post format: /%year%/%monthnum%/%postname%.html
On my rubencanton.com blog the RewriteRule isn’t index.html but blog/index.html:
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
# END WordPress
It should work.