Debian10升级到Debian12

如有报错,可移步 这里

前奏

rambo@debian:~$ su -
密码:

root@debian:~# apt install -y vim wget curl net-tools
root@debian:~# cat /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/debian/ buster main
deb-src http://mirrors.ustc.edu.cn/debian/ buster main

deb http://security.debian.org/debian-security buster/updates main contrib
deb-src http://security.debian.org/debian-security buster/updates main contrib


从Debian10升到11

root@debian:~# apt update && apt upgrade

# 清理配置文件残留
root@debian:~# find /etc -name '*.dpkg-*' -o -name '*.ucf-*' -o -name '*.merge-error'

从debian10升级到debian11

# 更新sources.list
root@debian:~# vim /etc/apt/sources.list
deb http://ftp.fr.debian.org/debian/ bullseye main non-free contrib
deb-src http://ftp.fr.debian.org/debian/ bullseye main non-free contrib

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

deb http://ftp.fr.debian.org/debian/ bullseye-backports main non-free contrib
deb-src http://ftp.fr.debian.org/debian/ bullseye-backports main non-free contrib

deb http://ftp.fr.debian.org/debian-security/ bullseye-security main non-free contrib
deb-src http://ftp.fr.debian.org/debian-security/ bullseye-security main non-free contrib



root@debian:~# apt update
root@debian:~# apt upgrade --without-new-pkgs -y         # 有时这一步要执行2次

检查升级是否成功
root@debian:~# cat /etc/issue
Debian GNU/Linux 11 \n \l

root@debian:~# 检查升级是否成功
root@debian:~# uname -mrs


从Debian11升级到debian12

root@debian:~# vim /etc/apt/sources.list
deb http://ftp.fr.debian.org/debian/ bookworm main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian/ bookworm main non-free non-free-firmware contrib

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

deb http://ftp.fr.debian.org/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian/ bookworm-backports main non-free non-free-firmware contrib

deb http://ftp.fr.debian.org/debian-security/ bookworm-security main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian-security/ bookworm-security main non-free non-free-firmware contrib



root@debian:~# apt update
root@debian:~# apt upgrade --without-new-pkgs -y


检查升级是否成功
root@debian:~# cat /etc/issue
Debian GNU/Linux 12 \n \l


root@debian:~# reboot
注:如果reboot前使用的dhcp,reboot后有可能会变,务必需要注意


root@debian:~# uname -mrs
Output: Linux 6.1.0-17-amd64 x86_64


遇到的问题

1、KDE Plasma桌面黑屏

reboot后遇到的问题是使用kde桌面上有图标,但是屏幕是黑色背景

把KDE桌面环境升级到 Debian 12 对应的版本(Plasma 5.27 左右):
root@debian:~# apt update
root@debian:~# apt install -y task-kde-desktop kde-standard kde-plasma-desktop plasma-workspace sddm


释义:
task-kde-desktop:Debian 提供的完整 KDE 套件任务包
kde-standard 和 kde-plasma-desktop:常规 KDE 桌面组件
plasma-workspace:桌面 shell,如果这个缺失会导致黑屏
sddm:KDE 默认登录管理器,也可能在升级中被破坏或替换



重新安装 Plasma 核心组件(必要时清理旧配置)
root@debian:~# apt install --reinstall plasma-desktop kde-plasma-desktop

如果还不能解决,尝试清除 Plasma 的本地配置(会丢失面板/快捷方式等自定义设置):
mv ~/.config/plasma*   ~/.config/plasma_backup/
mv ~/.config/kglobalshortcutsrc   ~/.config/kglobalshortcutsrc.bak


清理可能遗留的旧KDE包
root@debian:~# apt autoremove

确认是否使用 Wayland(默认应该是X11)
可尝试切换为 X11 会话登录(登录界面选择 Plasma (X11) 而不是 Plasma (Wayland)),Wayland在旧硬件或未完全升级情况下更容易黑屏

最后方案:完全重装KDE桌面(如果系统组件混乱严重)
root@debian:~# apt purge '^kde' '^plasma' '^qt'
root@debian:~# apt install -y task-kde-desktop




清除 Plasma 本地配置(将丢失桌面布局、面板配置等,但不会影响文件)
root@debian:~# exit
rambo@debian:~$ ls -alh .config/
mv ~/.config/plasma-org.kde.plasma.desktop-appletsrc{,-bak}
mv ~/.config/plasmashellrc{,-bak} 
mv ~/.config/plasma-localerc{,-bak}
mv ~/.config/plasma-nm{,-bak}


然后在图形化界面上注销用户,使用非root用户登录



补充

contrib
定义:contrib仓库包含的是那些自身是自由的软件,但是依赖于non-free仓库中的软件包才能运行的软件。虽然contrib中的软件本身遵守自由软件的准则,但由于它们依赖的软件不是完全自由的,所以被放在这个特殊的分类中。
示例:一个游戏可能是自由的并且源代码是开放的,但如果它需要一个非自由的游戏引擎才能运行,那么这个游戏就会被归类到contrib。

non-free
定义:non-free仓库包含的是那些不完全符合自由软件准则的软件。这些软件可能限制了修改或再分发的权利,或者以某种方式限制了使用。non-free并不意味着软件需要付费(虽然有些确实如此),而是指它们在许可证上有一些限制,不满足Debian自由软件准则的要求。
示例:一些驱动程序,专有软件或受版权保护的游戏就可能被放在non-free仓库中。

non-free-firmware
non-free-firmware是Debian 12 (Bookworm)发布准备过程中引入的一个新的仓库组件,专门用于存放那些非自由的固件。固件通常是预写入硬件设备中的软件程序,用于控制或使硬件设备运作。在很多情况下,硬件设备(如网卡、显卡等)需要特定的固件才能在Linux系统上正常工作。

将非自由固件分离到自己的仓库组件 non-free-firmware 的目的是为了清晰地区分完全自由的软件包和需要由于实用原因而包含的非自由固件。这样做允许Debian更好地组织和管理这些固件,同时也使得创建只包含自由软件但能够支持广泛硬件的安装镜像成为可能。


在debian10的LAMP上升级到debian12

在debian10上安装LAMP

rambo@debian:~$ su -
密码:


root@debian:~# cat /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/debian/ buster main
deb-src http://mirrors.ustc.edu.cn/debian/ buster main

deb http://security.debian.org/debian-security buster/updates main contrib
deb-src http://security.debian.org/debian-security buster/updates main contrib


root@debian:~# apt update && apt upgrade

# 清理配置文件残留
root@debian:~# find /etc -name '*.dpkg-*' -o -name '*.ucf-*' -o -name '*.merge-error'

安装nginx

和apache2二选一,本次选择安装nginx

root@debian:~# apt install -y nginx
root@debian:~# nginx -v
nginx version: nginx/1.14.2


root@debian:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2025-05-28 20:22:31 CST; 41s ago
     Docs: man:nginx(8)
 Main PID: 2171 (nginx)
    Tasks: 3 (limit: 4658)
   Memory: 5.0M
   CGroup: /system.slice/nginx.service
           ├─2171 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           ├─2172 nginx: worker process
           └─2173 nginx: worker process

5月 28 20:22:31 debian systemd[1]: Starting A high performance web server and a reverse proxy server...
5月 28 20:22:31 debian systemd[1]: Started A high performance web server and a reverse proxy server.



root@debian:~# apt install -y php  php-fpm
root@debian:~# php -v
PHP 7.3.31-1~deb10u7 (cli) (built: Jun 17 2024 21:48:38) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.31, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.31-1~deb10u7, Copyright (c) 1999-2018, by Zend Technologies


root@debian:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
root@debian:~# systemctl reload nginx



http://IP/info.php

安装apache2

root@debian:~# apt install -y apache2
root@debian:~# cd /var/www/html
root@debian:/var/www/html# vim info.php
<?php
phpinfo();

root@debian:~# apt install -y php libapache2-mod-php php-mysql       # 安装的是debian10中最新的


浏览器访问 http://172.16.186.158/info.php


安装MariaDB

root@debian:~# apt install -y mariadb-server

初始化数据库
root@debian:~# mysql_secure_installation
Enter current password for root (enter for none):           # 密码为空
Set root password? [Y/n] Y
New password:                                               # 密码是6个a
Re-enter new password: 

Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y


root@debian:~# mysql
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password;
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_root_passwd';
MariaDB [(none)]> exit


root@debian:~# mysql -u root -p
MariaDB [(none)]> select version();
+---------------------------+
| version()                 |
+---------------------------+
| 10.3.39-MariaDB-0+deb10u2 |
+---------------------------+
1 row in set (0.000 sec)


从debian10升级到Debian11

root@debian:~# vim /etc/apt/sources.list
deb http://ftp.fr.debian.org/debian/ bullseye main non-free contrib
deb-src http://ftp.fr.debian.org/debian/ bullseye main non-free contrib

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

deb http://ftp.fr.debian.org/debian/ bullseye-backports main non-free contrib
deb-src http://ftp.fr.debian.org/debian/ bullseye-backports main non-free contrib

deb http://ftp.fr.debian.org/debian-security/ bullseye-security main non-free contrib
deb-src http://ftp.fr.debian.org/debian-security/ bullseye-security main non-free contrib




root@debian:~# cat /etc/issue
Debian GNU/Linux 10 \n \l


root@debian:~# apt update

root@debian:~# apt upgrade --without-new-pkgs -y

root@debian:~# cat /etc/issue
Debian GNU/Linux 11 \n \l


检查升级是否成功
root@debian:~# uname -mrs
Linux 4.19.0-27-amd64 x86_64


root@debian:~# php -v
PHP 7.4.33 (cli) (built: Mar 19 2025 19:57:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies


root@debian:~# nginx -v
nginx version: nginx/1.18.0


================================================
root@debian:~# apache2 -version
Server version: Apache/2.4.62 (Debian)
Server built:   2024-10-04T15:21:08
================================================



root@debian:~# mysql -u root -p -e "select version();"
Enter password: 
+---------------------------+
| version()                 |
+---------------------------+
| 10.5.28-MariaDB-0+deb11u2 |              # 这里看到MariaDB的版本已经更改
+---------------------------+



# 切换为 TCP 而非 UNIX socket(兼容性更高)
root@debian:~# vim /etc/nginx/sites-available/default
location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass 127.0.0.1:9000;
}

=============================================
如果使用的sock则需看这个
root@debian:~# ls /run/php/
php7.4-fpm.pid	php7.4-fpm.sock  php-fpm.sock

=============================================


root@debian:~# systemctl reload php7.4-fpm
root@debian:~# systemctl reload nginx

从debian11升级到debian12

root@debian:~# vim /etc/apt/sources.list
deb http://ftp.fr.debian.org/debian/ bookworm main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian/ bookworm main non-free non-free-firmware contrib

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

deb http://ftp.fr.debian.org/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian/ bookworm-backports main non-free non-free-firmware contrib

deb http://ftp.fr.debian.org/debian-security/ bookworm-security main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian-security/ bookworm-security main non-free non-free-firmware contrib


root@debian:~# apt update

然后最小升级
root@debian:~# apt upgrade --without-new-pkgs -y      # 有时这一步要执行2次       

root@debian:~# cat /etc/issue
Debian GNU/Linux 12 \n \l



检查升级是否成功
root@debian:~# uname -mrs
Linux 4.19.0-27-amd64 x86_64


root@debian:~# php -v
PHP 8.2.28 (cli) (built: Mar 13 2025 18:21:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.28, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.28, Copyright (c), by Zend Technologies

==============================================
root@debian:~# apache2 -version
Server version: Apache/2.4.62 (Debian)
Server built:   2024-10-04T15:21:08

==============================================

root@debian:~# nginx -v
nginx version: nginx/1.22.1          # 注:如果你使用的是dhcp,则到这里后IP可能会变


root@debian:~# mysql -u root -p -e "select version();"
Enter password: 
+----------------------------+
| version()                  |
+----------------------------+
| 10.11.11-MariaDB-0+deb12u1 |              # 这里看到MariaDB的版本已经更改
+----------------------------+



root@debian:~# systemctl restart php8.2-fpm
root@debian:~# ss -ltnp | grep 9000
LISTEN 0      128        127.0.0.1:9000      0.0.0.0:*    users:(("php-fpm8.2",pid=7625,fd=10),("php-fpm8.2",pid=7624,fd=10),("php-fpm8.2",pid=7622,fd=8))


浏览器再访问 http://IP/info.php


root@debian:~# uname -mrs
Linux 4.19.0-27-amd64 x86_64


root@debian:~# reboot
注:如果reboot前使用的dhcp,reboot后有可能会变,务必需要注意

rambo@debian:~$ uname -mrs
Linux 6.1.0-37-amd64 x86_64


浏览器访问 http://IP/info.php 也能正常显示

posted @ 2025-05-28 21:53  Linux大魔王  阅读(219)  评论(0)    收藏  举报