Skip to main content

Upgrade Debian 11 to Debian 12

Description

In this article, we will describe the process of upgrading the OS from Debian 11 to Debian 12.

Upgrading

WARNING

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.

important

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.

  1. Make sure you have the correct repositories in /etc/apt/sources.list . The list of repositories for Debian 11 can be found below.
Debian 11 repositories
deb http://deb.debian.org/debian/ bullseye main contrib non-free
deb-src http://deb.debian.org/debian/ bullseye main contrib non-free

deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian/ bullseye-updates main contrib non-free

deb http://deb.debian.org/debian-security bullseye-security main contrib non-free
deb-src http://deb.debian.org/debian-security bullseye-security main contrib non-free
  1. Update all current packages to the latest versions
apt update && apt dist-upgrade
  1. Replace the list of repositories in /etc/apt/sources.list to repositories from Debian 12. The list of repositories for Debian 12 can be found below.
Debian 12 repositories
deb http://deb.debian.org/debian/ bookworm main contrib non-free
deb-src http://deb.debian.org/debian/ bookworm main contrib non-free

deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free
deb-src http://deb.debian.org/debian/ bookworm-updates main contrib non-free

deb http://deb.debian.org/debian-security bookworm-security main contrib non-free
deb-src http://deb.debian.org/debian-security bookworm-security main contrib non-free
  1. Resolving potential apache2 upgrade errors
a2dismod php7.4
  1. Update packages. Run the following commands one at a time
apt update
apt upgrade
apt dist-upgrade
  1. Updating other repositories
sed -i 's|bullseye|bookworm|g' /etc/apt/sources.list.d/*.list
  1. Add nginx repository keys
wget -q -O - http://nginx.org/keys/nginx_signing.key |apt-key add -
important

If MariaDB is used on the server, we need to correct the repository to specify a version of at least 10.11.

You can find out the version of the database server in use by running the command

mysql -V

If MySQL is used, correct the repository, update its key and add the Debian 11 security repository:

sed -i 's|bookworm|bullseye|g' /etc/apt/sources.list.d/mysql.list
echo "deb http://security.debian.org/debian-security bullseye-security main" > /etc/apt/sources.list.d/bullseye-security.list
wget -q -O - http://repo.mysql.com/RPM-GPG-KEY-mysql |apt-key add -

For MariaDB less then 10.5 use:

sed 's/10.[0-9]/11.1/' /etc/apt/sources.list.d/mariadb.list
  1. Update packages
apt update
apt dist-upgrade
  1. Install PHP 8.2 with base modules, PHP7.3-FPM and the Apache2 module
apt install -f php php-fpm libapache2-mod-php libapache2-mod-php8.2 php-common php8.2-cgi php8.2-cli php8.2-common php8.2-curl php8.2-gd php8.2-mbstring php8.2-mysql php8.2-opcache php8.2-readline php8.2-xml php8.2-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
  1. Move PHP-FPM configurations
mv /opt/php82/etc/php-fpm.d/* /etc/php/8.2/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/
  1. Replace PHP 7.4
apt-get purge php7.4*
  1. Activate PHP 8.2
a2enmod php8.2
  1. Correct PHP version in FASTPANEL base
sqlite3 /usr/local/fastpanel2/app/db/fastpanel2.db "update site set php_version = 82 where mode = 'mpm_itk';"
  1. Install the Dovecot component required for receiving mail
apt install dovecot-lmtpd
  1. Reconfigure services
mogwai services configure -f
  1. Additional configuration depending on the database server used

For MariaDB - run mysql_upgrade

mysql_upgrade
  1. Restart the server
reboot
  1. Make sure that all services are started after reboot
systemctl --failed

Upgrade complete.