华为云debian12服务器更新系统报错

错误信息:

E: Failed to fetch https://packages.sury.org/php/pool/main/p/php-defaults/php-common_96%2b0%7e20250402.56%2bdebian12%7e1.gbp84a5b7_all.deb  Temporary failure resolving 'packages.sury.org'
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-bcmath_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Could not connect to packages.sury.org:443 (151.101.111.52), connection timed out
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-zip_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-xml_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-readline_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-opcache_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-mysql_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-mbstring_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-intl_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-gd_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-cli_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-fpm_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-curl_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php8.3/php8.3-common_8.3.20-4%2b0%7e20250414.61%2bdebian12%7e1.gbp1029c4_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/p/php-imagick/php8.3-imagick_3.8.0%7erc2-3%2b0%7e20250408.50%2bdebian12%7e1.gbpd16435_amd64.deb  Unable to connect to packages.sury.org:https:
E: Failed to fetch https://packages.sury.org/php/pool/main/d/debsuryorg-archive-keyring/debsuryorg-archive-keyring_2025.03.13_all.deb  Unable to connect to packages.sury.org:https:
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
错误信息截图

问题分析:

这个错误说明 Debian 12 在更新或安装 PHP 包时,无法连接到 packages.sury.org。这是 PHP 的一个常用第三方源(由 Ondřej Surý 提供),经常用于安装更新版本的 PHP。但现在遇到了类似 DNS 解析失败或连接超时的问题。

解决办法:

出现这个问题的原因,大概率是因为packages.sury.org在国内访问不畅,可以使用以下方法尝试解决:

尝试切换服务器DNS,执行/etc/resolv.conf,添加以下内容:

nameserver 8.8.8.8
nameserver 1.1.1.1

然后再执行:

sudo apt update
sudo apt upgrade

如果还是不能解决,可以那么只能挂代码,或者切换源,不过 sury.org 很少有完整镜像,可能需要手动下载 .deb 包安装。

最后如果都无法解决,可以暂时注释掉 Sury 源。

我是通过修改DNS解决的问题。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注