Web 与数据

如何在 Linux Ubuntu 和 Debian 上安装 PHP 8.0

本文列出在 Ubuntu 和 Debian 上安装 PHP 8.0 所需的全部命令:先更新系统,Ubuntu 通过 ondrej/php 这个 PPA 软件源安装,Debian 则先添加 sury.org 软件源及其 GPG 密钥,最后再安装 php8.0 与 php8.0-fpm 软件包。

· 1 分钟阅读 · 难度 中级 · 基于 PHP 8.0

更新系统:

apt update

在 Ubuntu 上安装

apt install  ca-certificates apt-transport-https software-properties-common
add-apt-repository ppa:ondrej/php
apt update
apt install php8.0

在 Debian 上安装

apt install apt-transport-https lsb-release ca-certificates
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" > /etc/apt/sources.list.d/php.list
apt update
apt install php8.0
apt install php8.0-fpm