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.
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
Make sure you have the update manager core by running this command:
sudo apt-get install update-manager-core
Run the following command to begin the upgrade process. Ubuntu suggests running this from the console, though it should also work from SSH:
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**
/etc/apt/sources.list, and uncomment the Virtualmin repositories. Then change any references of
trusty in those repositories to
Run this command, and make sure the new apt config works properly:
**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
/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 `127.0.0.1` as a nameserver.
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.