Upgrading from Ubuntu 14.04 -> 16.04.1 under Amazon EC2

The Upgrade Process

I finally got around to upgrading my web server from Ubuntu 14.04 to Ubuntu 16.04.1. I decided to jot down my experiences in case anyone else runs into these issues.


The first thing I did prior to doing the upgrade was to run updraft plus to backup the Blog’s database and files. After that finished I logged into the Amazon EC2 console and created an image of my AMI. This way in the worst case scenario that I trashed my image I could just boot the backup image and be where I was before I began.

The next thing I did was check to see if I had screen installed. My thinking on these sorts of upgrades is you can easily lose your network connection and it is nice to be able to get right back to where you were without worrying about it if something goes wrong.

Beginning the upgrade

Ubuntu has a handy command:

 sudo do-release-upgrade

I invoked the command. It let me know that it would start ssh on an additional port just in case I got disconnected during the upgrade. I said yes to begin and it began downloading all the packages it needed. Amazon seems to have a ton of bandwidth so this step is super fast. Wouldn’t you know it but in the middle of this my network connection dropped. Luckily I was able to ssh back in and reattach to my screen session without issue. There were a couple of questions I had to answer about whether to keep a config file that I had modified or else replace it with the package maintainers. I made the decision for those questions based on looking at the diff to see if the differences in the files were important or not. At the end it asks to reboot to finalize the upgrade so I said yes.

The Aftermath

The machine booted up quickly and as soon as I was able to ssh in I logged into the website to see if everything was still working. I was promptly greated with a 502 Bad Gateway error. I started poking around and I could see that my nginx config hadn’t been changed and the service seemed to be running. At that point I figured it must be an issue with php-fpm. It turns out that it didn’t even have the package installed for php-fpm and the php packages that I did have were upgraded from 5.0 to 7.0. After googling around I was able to find out that the unix domain socket name and location have changed in the new version of php. I edited my default.conf for nginx and pointed it to the new socket location:

fastcgi_pass unix:/run/php/php7.0-fpm.sock;

That being done I needed to make some changes on the php-fpm side. The config file has moved where previous it was located under /etc/php5/fpm/pool.d/www.conf the new location is /etc/php/7.0/fpm/pool.d/www.conf

In this file I needed to update the following fields:

listen = /run/php/php7.0-fpm.sock
listen.owner = nginx = nginx

In this case I didn’t change the listen value I just used that value above to update my default.conf under nginx. After setting those values and restarting php7.0-fpm and nginx services my site was back up. Hopefully this will be helpful to anyone else who hits the same issue after they upgrade.


The downside of automatic updates

I have sort of taken for granted how easy all the updates are for a WordPress site. If there is a security update WordPress just goes up and updates itself without me doing anything and the plugin community is so active there are frequent updates to all of the plugins I used. Because it always just works I don’t really hesitate to run any of the updates when I see them on the site.

Obviously what happens next is no surprise yesterday I saw there was an update to 2 of my plugins so I just clicked upgrade and next thing you know when I clicked on any admin page I just got a blank white page. My first question was is my entire site down? So I checked and nope I could see all the content fine just couldn’t get into the admin.

They say every crisis is an opportunity and this sort of proves that point, I figured well no big deal I can deal with it later, and given that I don’t have SSH keys to this site on my work computer anyway I figured I would deal with it last night. Last night I did some googling and found out how to deal with a bad plugin install (basically rename your plugin dir and hit the plugin page which will disable all the plugins). I then renamed it back and updated the probably offending plugin as it had a new version already (and I had just updated during the day otherwise it had crashed in that update and it needed the update still), and then activated my plugins one by one and life is good.

So I am back up and running and the whole thing ended up being a good learning opportunity for me, but it prevented me from working on what I wanted to write about last night which was the Internet of Things Coding Workshop that I had attended, but that will come next.


Twitter Cards

I noticed that a bunch of people when they post to Twitter have much cooler looking posts than what the Jetpack plugin seemed to be doing for me on my blog. Over Thanksgiving I was looking into this a bit and discovered Twitter Cards. I am probably the last person on the internet finding out about them, but I hadn’t really paid that much attention to it previously. I decided maybe I should create a plugin to add them to the blog. But this being WordPress I did a search first and it looks like there is already a great one out there. This post is just me testing it out and seeing how it works. I often see people say that a great way to develop a little side income is to create a WordPress plugin and sell it. I actually wonder how people do that because it seems like every time I need some sort of plugin to add functionality to the blog I can find an amazing free plugin that does it for me. Anyway hopefully this test post works and I get a Twitter Card for it.


WordPress auto updates

I am always a little amazed when I get an email from my blog that tells me it upgraded software versions. Even though I have had auto-updating operating systems and other software for years, something about a website updating itself just seems like a bigger deal. I am sure most people think like whatever, but I think what a cool time we live in, when all this stuff just manages itself.