Bỏ qua để đến nội dung chính

Nâng cấp Debian 11 lên Debian 12

Mô tả

Trong bài viết này, chúng tôi sẽ mô tả quy trình nâng cấp OS từ Debian 11 lên Debian 12.

Nâng cấp

CẢNH BÁO

Trước khi nâng cấp hệ điều hành, chúng tôi đặc biệt khuyến nghị tạo bản sao lưu đầy đủ của tất cả dữ liệu trên máy chủ. Điều này sẽ đóng vai trò như một biện pháp bảo đảm trong trường hợp xảy ra sự cố, cho phép bạn khôi phục hệ thống trong tình huống khẩn cấp.

quan trọng

Tất cả các lệnh trong quá trình nâng cấp OS được thực thi trong terminal của máy chủ dưới người dùng root.

Từ chối các đề xuất của hệ thống về việc thay thế các tệp cấu hình (hành động mặc định).

Tên của các tệp repository trong /etc/apt/sources.list.d của OS của bạn có thể khác với những tên được sử dụng trong hướng dẫn này.

  1. Hãy chắc chắn rằng bạn có các repository chính xác trong /etc/apt/sources.list . Danh sách repository cho Debian 11 có thể được tìm thấy bên dưới.
Repository 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. Cập nhật tất cả các gói hiện tại lên phiên bản mới nhất
apt update && apt dist-upgrade
  1. Thay thế danh sách repository trong /etc/apt/sources.list bằng các repository từ Debian 12. Danh sách repository cho Debian 12 có thể được tìm thấy bên dưới.
Repository Debian 12
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. Giải quyết các lỗi nâng cấp apache2 tiềm ẩn
a2dismod php7.4
  1. Cập nhật các gói. Chạy từng lệnh sau đây, mỗi lần một lệnh
apt update
apt upgrade
apt dist-upgrade
  1. Cập nhật các repository khác
sed -i 's|bullseye|bookworm|g' /etc/apt/sources.list.d/*.list
  1. Thêm khóa repository nginx
wget -q -O - http://nginx.org/keys/nginx_signing.key |apt-key add -
quan trọng

Nếu MariaDB được sử dụng trên máy chủ, chúng ta cần điều chỉnh repository để chỉ định phiên bản ít nhất là 10.11.

Bạn có thể tìm ra phiên bản của máy chủ cơ sở dữ liệu đang được sử dụng bằng cách chạy lệnh

mysql -V

Nếu MySQL được sử dụng, hãy điều chỉnh repository, cập nhật khóa của nó và thêm repository bảo mật Debian 11:

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 -

Đối với MariaDB nhỏ hơn 10.5, hãy sử dụng:

sed 's/10.[0-9]/11.1/' /etc/apt/sources.list.d/mariadb.list
  1. Cập nhật các gói
apt update
apt dist-upgrade
  1. Cài đặt PHP 8.2 với các mô-đun cơ bản, PHP7.3-FPM và mô-đun Apache2
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. Di chuyển cấu hình PHP-FPM
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. Thay thế PHP 7.4
apt-get purge php7.4*
  1. Kích hoạt PHP 8.2
a2enmod php8.2
  1. Điều chỉnh phiên bản PHP trong cơ sở FASTPANEL
sqlite3 /usr/local/fastpanel2/app/db/fastpanel2.db "update site set php_version = 82 where mode = 'mpm_itk';"
  1. Cài đặt thành phần Dovecot cần thiết để nhận thư
apt install dovecot-lmtpd
  1. Cấu hình lại các dịch vụ
mogwai services configure -f
  1. Cấu hình bổ sung tùy thuộc vào máy chủ cơ sở dữ liệu được sử dụng

Đối với MariaDB - chạy mysql_upgrade

mysql_upgrade
  1. Khởi động lại máy chủ
reboot
  1. Đảm bảo rằng tất cả các dịch vụ đều được khởi động sau khi khởi động lại
systemctl --failed

Hoàn tất nâng cấp.