Debian12 安装 PHP8.3
当前 Debian12 官方源中带的 PHP 版本是8.2,而 PHP8.2 的 Active Support 到今年年底(31 Dec 2024),所以直接装8.3吧,可以用的时间长一点。
首先安装sury源
#!/bin/sh
# To add this repository please do:
if [ "$(whoami)" != "root" ]; then
SUDO=sudo
fi
${SUDO} apt-get update
${SUDO} apt-get -y install lsb-release ca-certificates curl
${SUDO} curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
${SUDO} dpkg -i /tmp/debsuryorg-archive-keyring.deb
${SUDO} sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
${SUDO} apt-get update
注意,如果安装sury源时报错: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B188E2B695BD4743,意思是系统缺少sury源的公钥。只要把公钥下载到系统就可以了,执行wget -qO /etc/apt/trusted.gpg.d/sury-php.gpg https://packages.sury.org/php/apt.gpg
,公钥添加完成后,执行apt update
刷新包列表即可。
然后执行
apt install -y php8.3-fpm php8.3-mysql php8.3-mbstring php8.3-curl php8.3-xml php8.3-imagick php8.3-zip php8.3-gd php8.3-intl php8.3-bcmath
如果需要支持 Laravel 框架,那么最后一个 bcmath 扩展是必须的。