Upgrade Ubuntu 16.04 to 18.04

Server runs

  • Traccar GPS Tracking software
  • WordPress
  • PHP 7.4.14
  • MySQL Ver 8.0.23

Notes:

I am using custom alias for stopping services.
I am also using AWS EC2 Server

Document version numbers and installed modules.

List PHP modules

ii  libapache2-mod-php7.4                 7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-common                            2:80~exp2+ubuntu16.04.1+deb.sury.org+1          all          Common files for PHP packages
ii  php7.4                                7.4.14-1+ubuntu16.04.1+deb.sury.org+1           all          server-side, HTML-embedded scripting language (metapackage)
ii  php7.4-cli                            7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        command-line interpreter for the PHP scripting language
ii  php7.4-common                         7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        documentation, examples and common module for PHP
ii  php7.4-curl                           7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        CURL module for PHP
ii  php7.4-fpm                            7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.4-gd                             7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        GD module for PHP
ii  php7.4-gmp                            7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        GMP module for PHP
ii  php7.4-intl                           7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        Internationalisation module for PHP
ii  php7.4-json                           7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        JSON module for PHP
ii  php7.4-mbstring                       7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        MBSTRING module for PHP
ii  php7.4-mysql                          7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        MySQL module for PHP
ii  php7.4-opcache                        7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        Zend OpCache module for PHP
ii  php7.4-readline                       7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        readline module for PHP
ii  php7.4-soap                           7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        SOAP module for PHP
ii  php7.4-xml                            7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        DOM, SimpleXML, XML, and XSL module for PHP
ii  php7.4-xmlrpc                         7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        XMLRPC-EPI module for PHP
ii  php7.4-zip                            7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        Zip module for PHP

List MySQL modules

ii  mysql-apt-config                      0.8.12-1                                        all          Auto configuration for MySQL APT Repo.
ii  mysql-client                          8.0.23-1ubuntu16.04                             amd64        MySQL Client meta package depending on latest version
ii  mysql-common                          8.0.23-1ubuntu16.04                             amd64        Common files shared between packages
ii  mysql-community-client                8.0.23-1ubuntu16.04                             amd64        MySQL Client
ii  mysql-community-client-core           8.0.23-1ubuntu16.04                             amd64        MySQL Client Core Binaries
ii  mysql-community-client-plugins        8.0.23-1ubuntu16.04                             amd64        MySQL Client plugin
ii  mysql-community-server                8.0.23-1ubuntu16.04                             amd64        MySQL Server
ii  mysql-community-server-core           8.0.23-1ubuntu16.04                             amd64        MySQL Server Core Binaires
ii  mysql-server                          8.0.23-1ubuntu16.04                             amd64        MySQL Server meta package depending on latest version
ii  mysqltuner                            1.6.0-1                                         all          high-performance MySQL tuning script
ii  php7.4-mysql                          7.4.14-1+ubuntu16.04.1+deb.sury.org+1           amd64        MySQL module for PHP

Backup & Take down traccar

export currentTraccarVersion=4.12
cp -rf /opt/traccar /opt/traccar-$currentTraccarVersion
traccar_down

Backup & Stop MYSQL

Backup Config file

cp /etc/mysql/mysql.conf.d/mysqld.cnf /root/mysqld.cnf-20211003
Create backup folder /backup/20211003-1604-1804/
# Warning. This might fill up disk.
for DB in $(mysql -u user -p -e 'show databases' -s --skip-column-names); do mysqldump -u root -p $DB > /backup/20211003-1604-1804/"$DB.sql"; done
mysql_down

Backup sysctl.conf

cp /etc/sysctl.conf /etc/sysctl.conf-20211003

Create Snapshot in AWS

Snapshot instructions

Take down S3 storage

This mounted s3 storage device can cause issues for me when bringing the server back up due to drive not found.

Unmount the drive

umount s3fs

I will comment it out from fstab

sed -i 's/s3fs/#s3fs/g' "/etc/fstab"

Ensure it’s unmounted

mount | grep s3fs

Perform update Ubuntu 16.04 to 18.04

Update 16.04 OS.

apt-get update
# Select OK to MySQL configuration option. Don't choose any to configure.
# Select OK to MySQL configuration option. Don't choose any to configure.
Y to keep package maintainers version of cnf file
apt-get upgrade -y
apt-get dist-upgrade -y

Check for problems

Reboot

Reboot

Perform Upgrade to 18.04

do-release-upgrade
Install package maintainers sysctl
Install package maintainers grub
Keep local version of 50-default.conf
Keep local version of sshd_conf
Remove obsolete packages
Y to restart

Fix php 7.4curl and CURL_OPENSSL_3

Follow this guide: https://www.digitalocean.com/community/tutorials/how-to-install-php-7-4-and-set-up-a-local-development-environment-on-ubuntu-18-04

apt remove --purge php7.4-curl
apt-get install php7.4-curl (may need to follow ondrej guide to enable the ondrej 7.4 repository. Cant remember if 18.04 natively supports 7.4)
apt-get install libcurl3 -y
apt-get install curl
service apache2 restart

Re-enable s3fs

sed -i 's/#s3fs/s3fs/g' "/etc/fstab"

Mount s3fs

mount -a

Check s3fs is mounted

mount | grep s3fs

Check logs for errors

tail_traccar
tail_mysql
dmesg | tail
tail_apache-error

Check cURL PHP is installed.

Check wordpress site & Traccar.

Leave a Reply