Note: you should stop apache before upgrade. You should back up your conf files, such as apache2.conf, php.ini, my.ini, and all VirtualHost settings.
Run simple command to upgrade.
sudo do-release-upgrade
After server restarted, login and STOP apache2 to prevent PHP short end breaks php rendering.
Enable new php short hand tag in php.ini if it is needed for your code.
sudo apt-get remove php7.2-common
sudo apt autoremove
sudo apt-get install -y php-pdo-mysql
sudo apt install php7.2-mysql php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-opcache php7.2-tidy php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-bcmath libapache2-mod-php
sudo apt-get install -y php7.2-bz2 php7.2-soap php7.2-dba
sudo a2enmod php7.2
you should see /etc/php/7.2 folder. if 7.0 old folder exists, delete it.
If you need php pdo for mysql and other common php modules
sudo service apache2 restart
NOTE: upgrade to ubuntu 18.04 which comes with mysql 5.7. To solve no default value issue, use following settign in my.ini
[mysqld] sql-mode="" # Or # sql-mode="NO_ENGINE_SUBSTITUTION"
---------------------
tip: for ubuntu 20.04 simple LAMP installation :https://niralar.com/install-lamp-web-server-on-amazon-ec2-with-ubuntu-20-04/