Updating Ubuntu 12.10 to 14.04 on Digital Ocean

Today I had set out to set up automatic deployment for my theme on this server using git. However, I hit a bump in the road when actually trying to install git: The old quantal repositories have been moved and so it wasn’t actually able to find the appropriate git package to install.

Being as inexperienced as I am with Linux, this was a little frustrating. Frantic Google searches resulted in mostly mixed and incomplete solutions. But for the most part, I’ve taken this opportunity to just get it over with and update Ubuntu to a version that isn’t EOL (End-of-Life).

So here’s this post, for those that are in the same situation as I and don’t feel like re-creating their installation on a new droplet. SSH into your server and let’s go!

But before you begin, make sure to create a snapshot as a back up. Just in case!

Update sources.list

First thing you will want to do is update the sources.list file that’s located at /etc/apt/sources.list. In here you’ll find a list of URLs where Ubuntu will try and look for packages. For Ubuntu 12.10 it’ll look like:

deb http://archive.ubuntu.com/ubuntu quantal main 
deb http://archive.ubuntu.com/ubuntu quantal-updates main 
deb http://security.ubuntu.com/ubuntu quantal-security main universe 
deb http://archive.ubuntu.com/ubuntu quantal universe 
deb http://archive.ubuntu.com/ubuntu quantal-updates universe

To update them, you will want to replace archive and security to old-releases. This is where Ubuntu keeps their older, unsupported, releases. Save the file and execute sudo apt-get update to update your package list from these “new” sources. Then, execute sudo apt-get upgrade to update all the packages that are currently installed on your server.

Update. Update. Update.

With the sources’ functionality restored, you should now be able to install packages again and also update your version of Ubuntu. Which means you can also install the update manager package to help you in the process. Do so by executing: sudo apt-get install update-manager-core. This will enable the do-release-upgrade command.

Executing this command now should find the 13.10 Saucy Salamander update. Unfortunately, it’s not possible to go straight to 14.04, so go through and install 13.10 first.

One of the first things you’re going to get asked is about whether or not you’d like for the update process to ask before restarting services or not. For the sake of convenience, select “Yes”. If you prefer to have more control, select “No”.

During the update, you may also get asked about configuration files that may have been changed. If you know absolutely sure you’ve not made your own modifications to a file, you should be fine selecting “install the package maintainer’s version”. For files like php.ini, it may be a good idea to “keep the local version currently installed”. When in doubt, it does allow you to look over the diffs in vi.

Depending on the amount of packages you’ve installed, the update should be fairly quick. Restart your server and then…do all of it again. This time, running sudo do-release-upgrade will find 14.04 Trusty Tahr and allow you to get up to date.

One more reboot after the update and you should be good to go. Make sure everything is running the way it should be and fix whatever isn’t. In my case, nginx was giving Bad Gateway errors after the update. A quick look at the error log showed me that they were permissions related. As it turns out, for some reason the php-fpm socket was being created by root.

To fix this, certain settings had to be re-enabled in /etc/php5/fpm/pool.d/www.conf. Specifically:

listen.owner = www-data
listen.group = www-data
listen.mode = 0666

Ensure that these are set to the owner/group nginx is set to use as well. By default this is www-data, but your set up may differ from mine. To find out, check your nginx conf (eg. /etc/nginx/nginx.conf) for a user line.

And that should be that. You will want to make sure to change the kernel setting in your Digital Ocean account to the appropriate version as well.

Should you run into any issues, feel free to let me know where you get stuck or what kind of errors you’re getting.