Nginx and MariaDB Issues Fix on Upgrading DigitalOcean Droplet from Ubuntu 14.04.5 to 16.04.1

Today after I updated the packages on my blog digital ocean droplet (here’s my entire wordpress setup) I discovered that it was ready to be upgraded to the new Ubuntu 16.04.1 LTS.

DigitalOcean already offers a wonderful guide for you to follow, but there were some caveats on my system that needed to be fixed before and after the upgrade.

Those were

  • MariaDB repository
  • Nginx failed to restart

here’s how I fixed it.

MariaDB Repo Authentication

If you followed my guide or configured your system with MariaDB it may happen that you get this error while upgrading your ubuntu

It was not possible to authenticate some packages. This may be a
transient network problem. You may want to try again later. See below
for a list of unauthenticated packages.

This might happen because the repo for the trusty has a different apt-key than the repo for the xenial.

To fix this head over at MariaDB Repository page  and search for the new xenial repo (be sure to take the same MariaDB version you have right now).

mariadb repositories keys
be sure to show all mirrors if you don’t find yours

Check the url of your mirror in the /etc/apt/sources.list to match the right one here.

This should fix the It was not possible to authenticate some packages. error 😉

Failed to start nginx.service: Unit nginx.service is masked.

This can happen once you have updated all your system and upgraded it, after the last reboot

Why this happens? My guess is that in Ubuntu 16.04 they moved onto systemctl which has a totally different way to behave compared to the old service model.

So, for reasons unknown to me, some services got masked (disabled) and therefore cannot start.
I cannot say the exact reason, but there’s obviously a way to fix it.

The Good Way – Unmasking

If you’re wondering why there’s a good and bad way, the reason is simple: I first stumbled upon the bad way and used it myself, but couldn’t believe that it was the right solution.
I used systemctl on other vps machines and never had this problem, so there should have been a better way.

And there it is 🙂 you use the systemctl to unmask it and then re-enable it correctly.

sudo systemctl unmask nginx.service
sudo systemctl enable nginx.service
sudo systemctl restart nginx.service

The Raw and Bad way – removing the file

If you search the web you’ll also find this way of fixing the problem, which is not the best (but still works) and it’s made of one simple command (I added a backup, just in case)

sudo cp /etc/systemd/system/nginx.service /root/nginx.service.backup
sudo rm /etc/systemd/system/nginx.service
sudo reboot

Conclusions

Every time I upgrade a system I am always worried, and as such I advice you to always take a snapshot of your VPS to keep just in case it goes wrong.

Aside from this, there were many things that worked flawlessly so these 2 issues are minor compared to the whole upgrade, although it did scare me to death.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: