Upgrade Ubuntu 20 to Ubuntu 22
Description
In this article, we will describe the process of upgrading the OS from Ubuntu 20.04
to Ubuntu 22.04
.
Upgrading
Before upgrading the operating system, we strongly recommend making a full backup of all data on the server. This will serve as an insurance policy in case of problems, allowing you to restore the system in the event of an emergency.
All commands during OS upgrade are executed in the server terminal under the root user.
Refuse system suggestions to replace configuration files (default action).
The names of repository files in /etc/apt/sources.list.d
of your OS may be different from those used in these instructions.
- Make sure you have the correct repositories in
/etc/apt/sources.list
. The list of repositories for Ubuntu 18.04 can be found below.
Ubuntu 20 repositories
### Main repo for Ubuntu focal
deb https://mirrors.xtom.ee/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.xtom.ee/ubuntu/ focal main restricted universe multiverse
### Updates repo for Ubuntu focal
deb https://mirrors.xtom.ee/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.xtom.ee/ubuntu/ focal-updates main restricted universe multiverse
### Security repo for Ubuntu focal
deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse
### Backports repo for Ubuntu focal
deb https://mirrors.xtom.ee/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.xtom.ee/ubuntu/ focal-backports main restricted universe multiverse
### Proposed repo for Ubuntu focal
deb http://archive.ubuntu.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-proposed main restricted universe multiverse
- Update all current packages to the latest versions
apt update && apt dist-upgrade
- Resolve potential proftpd and apache2 upgrade errors
a2dismod php7.4
sed -e 's/^IdentLookups/#IdentLookups/' -i /etc/proftpd/proftpd.conf
- Run the upgrade
do-release-upgrade --allow-third-party
If for some reason the utility is not installed, you can fix it with the command
apt install update-manager-core
Carefully read the output of the utility before confirming, make sure that nothing unnecessary will be deleted in the process.
The upgrade is considered successful if the system prompts you to restart the server.
Accept the reboot
- Install PHP 8.1 with base modules, PHP8.1-FPM and the module for Apache2
apt install -f php php-fpm libapache2-mod-php libapache2-mod-php8.1 php-common php8.1-cgi php8.1-cli php8.1-common php8.1-curl php8.1-gd php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-readline php8.1-xml php8.1-xmlrpc php-imagick php-memcached
phpenmod calendar ctype curl dom exif fileinfo ftp gd gettext iconv mbstring mysqli mysqlnd pdo pdo_mysql phar posix readline shmop simplexml sockets sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlrpc xmlwriter xsl opcache imagick memcached
- Replace PHP-FPM configuration
mv /opt/php81/etc/php-fpm.d/* /etc/php/8.1/fpm/pool.d/
rm /etc/php/7.4/fpm/pool.d/www.conf
mv /etc/php/7.4/fpm/pool.d/* /opt/php74/etc/php-fpm.d/
- Remove PHP 7.4
apt purge php7.4*
- Activate PHP 8.1
a2enmod php8.1
- Correct PHP version in FASTPANEL base
sqlite3 /usr/local/fastpanel2/app/db/fastpanel2.db "update site set php_version = 81 where mode = 'mpm_itk';"
- Reconfigure services
mogwai services configure -f
- Restart the server
reboot
- Make sure that all services are started after reboot
systemctl --failed
Upgrade complete.