メインコンテンツにスキップ

Debian 10 を Debian 11 にアップグレードする

説明

この記事では、OS を Debian 10 から Debian 11 にアップグレードする手順を説明します。

アップグレード

警告

オペレーティングシステムをアップグレードする前に、サーバー上のすべてのデータの完全なバックアップを作成することを強く推奨します。 これにより、問題が発生した場合の保険となり、緊急時にシステムを復元できます。

重要

OS のアップグレード中のすべてのコマンドは、root ユーザーでサーバーのターミナル上で実行します。

構成ファイルを置き換えるというシステムの提案は拒否してください(デフォルトの動作)。

ご使用の OS の /etc/apt/sources.list.d にあるリポジトリファイル名は、この手順で使用されているものと異なる場合があります。

  1. /etc/apt/sources.list に正しいリポジトリがあることを確認してください。 Debian 9 のリポジトリ一覧は以下にあります。
Debian 10 のリポジトリ
deb http://archive.debian.org/debian/ buster main contrib non-free
deb-src http://archive.debian.org/debian/ buster main contrib non-free

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

deb http://archive.debian.org/debian-security buster/updates main contrib non-free
deb-src http://archive.debian.org/debian-security buster/updates main contrib non-free
  1. 現在のすべてのパッケージを最新バージョンに更新します
apt update && apt dist-upgrade
  1. /etc/apt/sources.list 内のリポジトリ一覧を Debian 11 のものに置き換えます。 Debian 11 のリポジトリ一覧は以下にあります。
Debian 11 のリポジトリ
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://security.debian.org/debian-security bullseye-security main contrib non-free
deb-src http://security.debian.org/debian-security bullseye-security main contrib non-free
  1. ProFTPD の更新時に発生する可能性のあるエラーを解消する
sed -e 's/^IdentLookups/#IdentLookups/' -i /etc/proftpd/proftpd.conf
  1. パッケージを更新します。 次のコマンドを1つずつ実行する
apt update
apt upgrade
apt dist-upgrade
  1. 他のリポジトリを更新します
sed -i 's|buster|bullseye|g' /etc/apt/sources.list.d/*.list
  1. nginx リポジトリキーを追加する
wget -q -O - http://nginx.org/keys/nginx_signing.key |apt-key add -
重要

Debian 11 のリポジトリには、古いバージョンのデータベースサーバーはありません。 さらにアップグレードするには、/etc/apt/sources.list.d/ で MySQL と MariaDB にそれぞれバージョン 8.0 と 10.5 を指定する必要があります。 現在のデータベースサーバーのバージョンは、次のコマンドを実行して確認できます

mysql -V

MySQL を使用している場合は、パッケージのバージョンを変更し、リポジトリキーを追加します:

sed -i 's/mysql-5.7/mysql-8.0/g' /etc/apt/sources.list.d/mysql.list
wget -q -O - http://repo.mysql.com/RPM-GPG-KEY-mysql |apt-key add -

10.5 未満の MariaDB の場合は、次を使用します:

sed -i 's/10.[0-4]/10.9/' /etc/apt/sources.list.d/mariadb.list
  1. パッケージを更新します
apt update
apt dist-upgrade
  1. ベースモジュール、PHP7.3-FPM、および Apache2 モジュールとともに PHP 7.3 をインストールします
dpkg -l | awk '/php7.3/ {print $2}' | sed -e 's/7.3/7.4/'  | xargs apt install -y

apt install -f php php-fpm libapache2-mod-php libapache2-mod-php7.4 php-common php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-xmlrpc php-imagick php-memcached

phpenmod calendar ctype curl dom exif fileinfo ftp gd gettext iconv json mbstring mysqli mysqlnd pdo pdo_mysql phar posix readline shmop simplexml sockets sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl opcache imagick memcached
  1. PHP-FPM の構成を置き換えます
mv /opt/php74/etc/php-fpm.d/* /etc/php/7.4/fpm/pool.d/

rm /etc/php/7.3/fpm/pool.d/www.conf

mv /etc/php/7.3/fpm/pool.d/* /opt/php73/etc/php-fpm.d/
  1. PHP 7.3 を削除します
apt purge php7.3*
  1. PHP 7.4 を有効化します
a2enmod php7.4
  1. FASTPANEL ベース内の PHP バージョンを修正します
sqlite3 /usr/local/fastpanel2/app/db/fastpanel2.db "update site set php_version = 74 where mode = 'mpm_itk';"
  1. メール受信に必要な Dovecot コンポーネントをインストールします
apt install dovecot-lmtpd
  1. サービスを再設定します
mogwai services configure -f
  1. 使用しているデータベースサーバーに応じた追加設定

MySQL 8 の場合 - 互換性設定を追加します

echo 'disable-log-bin
mysqlx = OFF
default-authentication-plugin = mysql_native_password
character-set-server = utf8
collation-server = utf8_unicode_ci
' >> /etc/mysql/my.cnf.fastpanel/99-fastpanel.cnf

MariaDB の場合 - mysql_upgrade を実行します

mysql_upgrade
  1. サーバーを再起動します
reboot
  1. 再起動後にすべてのサービスが起動していることを確認します
systemctl --failed

アップグレードが完了しました。