将 Debian 9 升级到 Debian 10
说明
本文将介绍将操作系统从 Debian 9 升级到 Debian 10 的过程。
升级
警告
在升级操作系统之前,我们强烈建议对服务器上的所有数据进行完整备份。 这可以在出现问题时作为保障,使您能够在紧急情况下恢复系统。
重要
在操作系统升级 期间,所有命令都以 root 用户身份在服务器终端中执行。
当系统建议替换配置文件时,请拒绝(默认操作)。
您操作系统中 /etc/apt/sources.list.d 的仓库文件名称可能与本说明中使用的名称不同。
- 请确保
/etc/apt/sources.list中的仓库配置正确。 下方提供了 Debian 9 的仓库列表。
Debian 9 仓库
deb http://archive.debian.org/debian/ stretch main contrib non-free
deb-src http://archive.debian.org/debian/ stretch main contrib non-free
deb http://archive.debian.org/debian-security/ stretch/updates main contrib non-free
deb-src http://archive.debian.org/debian-security/ stretch/updates main contrib non-free
- 将当前所有软件包更新到最新版本
apt update && apt dist-upgrade
- 将
/etc/apt/sources.list中的仓库列表替换为 Debian 10 的仓库。 下方提供了 Debian 10 的仓库列表。
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
- 更新软件包。 依次运行以下命令
apt update
apt upgrade
apt dist-upgrade
- 更新其他仓库
sed -i 's|stretch|buster|g' /etc/apt/sources.list.d/*.list
- 添加 MySQL 和 nginx 的仓库密钥
wget -q -O - http://repo.mysql.com/RPM-GPG-KEY-mysql |apt-key add -
wget -q -O - http://nginx.org/keys/nginx_signing.key |apt-key add -
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29
- 更新软件包
apt update
apt dist-upgrade
- 安装 PHP 7.3 及基础模块、PHP7.3-FPM 和 Apache2 模块
dpkg -l | awk '/php7.0/ {print $2}' | sed -e 's/7.0/7.3/' | grep -v mcrypt | xargs apt install -y
apt install -f php php-fpm libapache2-mod-php libapache2-mod-php7.3 php-common php7.3-cgi php7.3-cli php7.3-common php7.3-curl php7.3-gd php7.3-json php7.3-mbstring php7.3-mysql php7.3-opcache php7.3-readline php7.3-xml php7.3-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
- 替换 PHP-FPM 配置
mv /opt/php73/etc/php-fpm.d/* /etc/php/7.3/fpm/pool.d/
rm /etc/php/7.0/fpm/pool.d/www.conf
mv /etc/php/7.0/fpm/pool.d/* /etc/php/7.3/fpm/pool.d/
- 删除 PHP 7.0
apt purge php7.0*
- 启用 PHP 7.3
a2enmod php7.3
- 修正 FASTPANEL 数据库中的 PHP 版本
sqlite3 /usr/local/fastpanel2/app/db/fastpanel2.db "update site set php_version = 73 where mode = 'mpm_itk';"
- 修复 dovecot
mv /etc/dovecot/private/dovecot{.pem,.key}
mv /etc/dovecot/dovecot.pem /etc/dovecot/private/dovecot.pem
apt install dovecot-lmtpd
- 重新配置服务
mogwai services configure -f
- 重启服务器
reboot
- 重启后请确保所有服务都已启动
systemctl --failed
升级完成