Apache, PHP, Security, Troubleshooting, Web

Ubuntu 12.04.5 LTS to 14.04.4 LTS Upgrade on Apache Web Server – Steps, Issues/Fixes & Tips

I was recently upgrading a Ubuntu server from 12.04.5 LTS to 14.04.4 LTS and for the most part had a pleasant experience. I’m going to attempt to document my steps I used for the upgrade below and comment to any issues I found (and tips to fix).

  • I ran the following to download the most up-to-date set of updates and packages to upgrade on the system:
sudo apt-get update

Issue: When I first was experimenting on a clone I noticed after running this command I received a bunch of 503s on the apt-get attempt.

Fix: After opening up the firewall to allow outbound traffic to http://us.archive.ubuntu.com then the Get attempts were successful.

  • Once I received the most up-to-date set of updates and packages I ran the command to perform the upgrade:
sudo do-release-upgrade -d

Tips:

  • You may be prompted about disabling ssh authentication for root. If you are unsure of whether this is enabled/disabled previously my recommendation is that you leave the default of “No” and enable it if you need it after the fact.

root_warning_14_04_ubuntu_u

  • If prompted about being asked to automatically allow restarts of services without notification you may want to consider saying no if you have a significant amount of upgrades.

sshot-server-3

Once the upgrade/removal process is complete you are (usually) prompted to restart the server itself. Should you not be prompted for such you can run the following command to restart the server:

sudo reboot

Now then, you should now have your server up to date and installed. This should mean your web site comes right up without problems, right? Wrong. Chances are you need to go and verify everything still runs after the upgrade. I’ll show what issues I ran into below as proof of that concept.

Issue: All web sites that previously worked before the upgrade now come up with “401 Unauthorized”

Fix: As a part of the Apache2 update in Ubuntu 14.04.4 all of the virtual host files in /etc/apache2/sites-enabled folder have to be updated to have .conf appended to them.

So in this example I had a file called my.website.com that I need to be my.website.com.conf, I made this change using:

cp my.website.com my.website.com.conf

Once I updated all of the files to use .conf related to my web sites I restarted apache2 to enforce the changes:

sudo /etc/init.d/apache2 restart

After this I was able to see my sites as I expect. Now I am seeing some odd error messages at the top…let’s dig a bit more.

Issue: I started getting some unhandled error exceptions (8192) that were in some error handling code

Here was the snippet before I made changes that had the problem:

$errorTypeLookup = array (
E_ERROR => 'PHP Fatal error',
E_DB_ERROR => 'Database Error',
E_SYSTEM_ERROR => 'System Error',
E_SECURITY_ERROR => 'Security Error',
E_VISIBLE => 'Warning',
E_WARNING => 'PHP Warning',
E_PARSE => 'PHP Parse error',
E_NOTICE => 'PHP Notice',
E_CORE_WARNING => 'PHP Core Warning',
E_COMPILE_WARNING => 'PHP Compile Warning',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'PHP Runtime Notice',
);

Fix: If you read here about error function contstants you’ll find the introduction of 3-4 newer ones after PHP 5.2. The one in particular that I needed to add (related to 8192) was E_DEPRECATED. After I added it (and a couple others) and restarted apache2 those particular issues went away. Below is my updated snippet:

$errorTypeLookup = array (
E_ERROR           => 'PHP Fatal error',
E_DB_ERROR        => 'Database Error',
E_SYSTEM_ERROR    => 'System Error',
E_SECURITY_ERROR  => 'Security Error',
E_RECOVERABLE_ERROR     => 'Recoverable Error',
E_DEPRECATED      => 'Deprecated',
E_USER_DEPRECATED => 'User Deprecated',
E_VISIBLE         => 'Warning',
E_WARNING         => 'PHP Warning',
E_PARSE           => 'PHP Parse error',
E_NOTICE          => 'PHP Notice',
E_CORE_WARNING    => 'PHP Core Warning',
E_COMPILE_WARNING => 'PHP Compile Warning',
E_USER_WARNING    => 'User Warning',
E_USER_NOTICE     => 'User Notice',
E_STRICT          => 'PHP Runtime Notice',
);

After I worked through these issues my web sites functioned as expected. Please do understand that based on your web sites/apps that these steps and issues/fixes will always be unique. The good thing is that for the most part what is documented on the internet will usually help guide you through particular problems you are facing. I hope this helps, questions are always welcome.

Helpful links: