韌館-LearnHouse

升級PHP出現Couldn't find any package by glob 'php8.2'

資料來源:https://www.thedataops.org/how-to-upgrade-php-version-from-8-1-to-8-2-in-ubuntu

正常升級PHP會經過以下步驟

Add PPA for PHP 8.2

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

Install PHP 8.2

sudo apt install php8.2

但執行install php8.2卻出現

sudo apt install php8.2
正在讀取套件清單… 完成
正在重建相依關係… 完成
正在讀取狀態資料… 完成
E: 找不到套件 php8.2
E: Couldn't find any package by glob 'php8.2'

只要新增https://packages.sury.org/php到php.list即可

echo "deb https://packages.sury.org/php/ bullseye main" > /etc/apt/sources.list.d/php.list

但卻又出現

yuchin@raspi:/home3$ sudo apt-get update
Get:1 https://packages.sury.org/php bullseye InRelease [7551 B]
Hit:2 http://ppa.launchpad.net/ondrej/php/ubuntu hirsute InRelease
Err:1 https://packages.sury.org/php bullseye InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B188E2B695BD4743
Hit:3 http://old-releases.ubuntu.com/ubuntu hirsute InRelease
Hit:4 http://old-releases.ubuntu.com/ubuntu hirsute-updates InRelease
Hit:5 http://old-releases.ubuntu.com/ubuntu hirsute-backports InRelease
Hit:6 http://old-releases.ubuntu.com/ubuntu hirsute-security InRelease
Reading package lists… Done
W: GPG error: https://packages.sury.org/php bullseye InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B188E2B695BD4743
E: The repository 'https://packages.sury.org/php bullseye InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

透過以下方式設定但這裡的B188E2B695BD4743要換成你執行時出現的public number

gpg --keyserver pgpkeys.mit.edu --recv-key B188E2B695BD4743
gpg -a --export B188E2B695BD4743 | sudo apt-key add -

就可以繼續

Install PHP 8.2 Packages

sudo apt install php8.2-common php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-curl php8.2-gd php8.2-imagick php8.2-cli php8.2-dev php8.2-imap php8.2-mbstring php8.2-opcache php8.2-soap php8.2-zip php8.2-intl -y

PHP 8 Enable

sudo a2dismod php7.3
sudo a2enmod php8.2
sudo service apache2 restart

2023年12 月 posted by admin in 網誌歷程 and have No Comments

Place your comment

Please fill your data and comment below.
名稱:
信箱:
網站:
您的評論: