PHP and Apache2 broken after upgrade to Ubuntu 16.04

Solution 1:

Ubuntu 16.04 comes with PHP 7.0. You need to install libapache2-mod-php package and then disable all traces of PHP5.

  1. Uninstall PHP5.x package: sudo apt-get purge php5-common (this will remove all PHP 5 packages.
  2. Install default (7.0) PHP apache2 SAPI: sudo apt-get install libapache2-mod-php
  3. If the apache2 is still broken do: sudo rm /etc/apache2/mods-enabled/php5.* to disable PHP5 mod and enable PHP 7.0 with sudo a2enmod php7.0.

Solution 2:

If you are running www from ~userdir/public_html, check the below in /etc/apache2/mods-enabled/php7.0.conf

# Running PHP scripts in user directories is disabled by default
#
# To re-enable PHP in user directories comment the following lines
# from <IfModule ...> to </IfModule>