Upgrading Ubuntu 14.04 Trusty to 16.04 Xenial

This document will guide you through upgrading an Ubuntu 14.04 (Trusty) server to an Ubuntu 16.04 (Xenial) server.

We highly recommend that you perform all of these steps on a test system before making changes to your production server -- that way, you can minimize downtime by knowing what to expect.

You should plan for some downtime -- there are big differences between the two distributions, and things don't always go as smoothly as we would hope.

You can see the full release notes here (we'd recommend reading these before performing an upgrade):


Ubuntu 16.04 comes with PHP 7.0. Verify that your PHP applications support that PHP version.

For those wishing to upgrade, the following steps will guide you through the process --

Upgrade Guide


Make sure you have full backups of everything on your server that is important to you. At the very least, you should generate full backups of all your Virtual Servers. You may also want to make a backup of everything in /etc.

Package Updates

Make sure your system is fully up to date by running these commands:

sudo apt-get update
sudo apt-get upgrade

Reset Dependency Flags

These packages are already installed, but the following command will tell apt not include them anytime "apt-get autoremove" is run:

apt-get install bind9 spamassassin spamc procmail libnet-ssleay-perl libpg-perl libdbd-pg-perl libdbd-mysql-perl quota iptables openssl python mailman subversion ruby irb rdoc ri mysql-server mysql-client mysql-common postgresql postgresql-client awstats webalizer dovecot-common dovecot-imapd dovecot-pop3d proftpd webmin usermin webmin-virtual-server libcrypt-ssleay-perl webmin-virtual-server-theme webmin-virtualmin-awstats webmin-virtualmin-htpasswd clamav-base clamav-daemon clamav clamav-data clamav-freshclam clamav-docs clamav-testfiles libapache2-mod-fcgid scponly apache2 apache2-doc libapache2-svn libsasl2-2 libsasl2-modules sasl2-bin procmail-wrapper php-pear php5 php5-cgi webmin-security-updates

Update Manager

Make sure you have the update manager core by running this command:

sudo apt-get install update-manager-core

Begin Upgrade

Run the following command to begin the upgrade process. Ubuntu suggests running this from the console, though it should also work from SSH:

do-release-upgrade -d

And then follow the on-screen instructions.

If you are prompted about whether to replace a config file with a new one, or keep your existing one -- we would suggest keeping your existing config.

Other than that, we suggest using the default options when presented with choices during the upgrade process.


Now is an excellent time to go get some coffee or another beverage of choice, while the packages are downloaded and installed :-)


When the upgrade completes, it will prompt you to reboot your system. Perform the reboot, and when your system comes back online, there's just a few more things to change.

Change apt config

Edit /etc/apt/sources.list, and uncomment the Virtualmin repositories. Then change any references of trusty in those repositories to xenial.

Run this command, and make sure the new apt config works properly:

apt-get update

PHP and Apache

Our testing showed that it didn't always properly upgrade from PHP5 to PHP7, leaving a mix of packages in a non-working state. The section below describes how to correct that.

First, run this command to remove the PHP5 packages:

apt-get remove 'php5*'

It should then prompt to remove the older PHP5 packages, and offer to bring in (some of) the PHP7 packages.

Some packages are likely to be missing still, these commands will resolve that:

apt-get purge libapache2-mod-php5
apt-get install apt-get install php7.0-cgi php7.0-mysql libapache2-mod-php7.0

Now edit /etc/apache2/mods-enabled/php7.0.conf, and comment out all the lines beginning with the word SetHandler. There should be two of them.

Lastly, all the wrapper scripts Virtualmin uses for FCGID and CGI are pointing to "/usr/bin/php5-cgi", but that no longer exists on this distribution. We can fix that by creating this symlink:

ln -s /usr/bin/php-cgi /usr/bin/php5-cgi

You should now be able to start Apache:

service apache2 start

Verify DNS Config

Edit /etc/resolv.conf, and verify that the nameserver line is configured to use as a nameserver.

Virtualmin Test

Now, log into Virtualmin, and go into System Settings -> Re-Check Config, and verify that it doesn't detect any problems.


If you've got this far, now it's time to test your websites!

If you run into any problems, check the Apache error logs for your website, located in $HOME/logs/error_log. Be sure that the PHP modules your application uses are installed, not all PHP modules are brought in properly during the upgrade process.



An update on this problem...

After updating to Ubuntu 16, I am having trouble with my websites.

For an Owncloud installation, I can only access my login page, which gives me the following error: "Cannot write into "config" directory! This can usually be fixed by giving the webserver write access to the config directory."

I've checked the ownership and permissions and they seem to be in place, with the virtual server owner as the web server user (instead of www-data or apache).

A similir problem spang up for a WP site in the same server, I can access most of it, but when upgrading plugins I get the following: "An error occurred while updating WooCommerce: Could not create directory."

However, for other plugins I am successful in updating.

These may be two separate issues but they do however look very similar, and I wasn't experiencing either of them previous to upgrading to Ubuntu 16.

Any clues on how to solve this??

A quick update on this problem -- Considering the changes in PHP, Apache and MySQL configuration involved in the Ubuntu 16 upgrade, it's easy to see

The Owncloud problem I was able to sort out by updating the folder permissions. However, I'm still experiencing the problem on my WP installation, where I can't update several plugins based on the "could not create directory" problem.

I've tried several folder permission changes, and gone through the config files, the website options in Virtualmin.

Any suggestions would be greatly appreciated.

Regards, Francisco

Hi all,

Just a quick update on the issue, I was able to solve the issue and have all of my sites work nicely again by commenting out the "Set Handler" lines in the apache configuration files. I had done it before for the "mods-available" php7.conf file, yet I missed doing the same in the following file:


Hope this helps...


After doing all the above, I still had a problem with php. This was from an upgrade that went from 12.04 -> 14.04 -> 16.04 sequentially.

The file /home/DOMAIN/fcgi-bin/php7.0.fcgi had a line that pointed to a non-existent binary for "exec". Changed it (had to use chattr, why???) to:

exec /usr/bin/php-cgi7.0

and my php site started working. Then you need to update all the sites' PHP settings to update them to 7.0.

Then there was Dovecot. It needed a:

namespace inbox {
     inbox = yes

in /etc/dovecot/conf.d/10-mail.conf or all logins would get errors. Ugh. There were a couple of packages that Roundcube wanted (php-zip was one), and I pretty much HAD to upgrade to Roundcube 1.2.2 to get it to work. Not sure how to do this in an automated way; just did it for one domain so far.

Next problem is that the Roundcube installer script wants php5-mysql, which was de-installed by the above actions.

Not sure what to do about that -- the installer wants to apt-get install it. Is there a way to get to the script or whatever that does this installation and remove this dependency?

"apt-get install apt-get install …" there is one "apt-get install" too much ;-)