跳转到主要内容

将 Debian 10 升级到 Debian 11

说明

本文将介绍将操作系统从 Debian 10 升级到 Debian 11 的过程。

升级

警告

在升级操作系统之前,我们强烈建议对服务器上的所有数据进行完整备份。 这样可以在出现问题时作为保障,使您能够在紧急情况下恢复系统。

重要

操作系统升级期间的所有命令都需在服务器终端中以 root 用户身份执行。

当系统提示替换配置文件时,请拒绝(默认操作)。

您操作系统中 /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. 更新软件包。 依次运行以下命令
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. 安装 PHP 7.3 及基础模块、PHP7.3-FPM 和 Apache2 模块
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

升级完成。