====== Debian 10 升級 php 至 7.4 ====== * 升級環境 : Debian GNU/Linux 10 \n \l * 原本安裝 php 7.3 ===== 升級程序 ===== - 進行已安裝套件更新 apt update apt upgrade -y - 下載 PHP 7.4 的 Sury PPA 與設定 apt -y install lsb-release apt-transport-https ca-certificates wget wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list - Apache 環境安裝 PHP 7.4 apt update apt install php7.4 php -v a2dismod php7.3 a2enmod php7.4 - 可以至 /etc/apache2/mods-enabled 看是否已經切換為 php7.4 - 重新啟動 apache2 service apache2 restart * **php相關套件的安裝** * 原有 php 7.3 所安裝的套件也需要配合安裝 php 7.4 版本相對套件 * 查詢已安裝的套件清單 apt list --installed | grep php php7.3-cli/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-common/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-curl/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-gd/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-json/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-mbstring/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-mysql/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-opcache/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-readline/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-xml/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.3-zip/oldoldstable,now 7.3.31-1~deb10u4 amd64 [installed,upgradable to: 7.3.33-11+0~20230612.108+debian10~1.gbp1f186d] php7.4-cli/buster,now 1:7.4.33-6+0~20230609.83+debian10~1.gbp32abef amd64 [installed,automatic] php7.4-common/buster,now 1:7.4.33-6+0~20230609.83+debian10~1.gbp32abef amd64 [installed,automatic] php7.4-json/buster,now 1:7.4.33-6+0~20230609.83+debian10~1.gbp32abef amd64 [installed,automatic] php7.4-opcache/buster,now 1:7.4.33-6+0~20230609.83+debian10~1.gbp32abef amd64 [installed,automatic] php7.4-readline/buster,now 1:7.4.33-6+0~20230609.83+debian10~1.gbp32abef amd64 [installed,automatic] php7.4/buster,now 1:7.4.33-6+0~20230609.83+debian10~1.gbp32abef all [installed] * 發現還有 curl, gd, mbstring mysql xml zip 套件需要安裝 apt install php7.4-curl php7.4-gd php7.4-mbstring php7.4-mysql php7.4-xml php7.4-zip * 安裝後重啟 apache2 service apache2 restart ===== 參考網址 ===== * https://www.cloudbooklet.com/install-php-7-4-on-debian-10/ {{tag>php}}