安装 MySQL 8.0 所需的软件包
sudo apt install dirmngr software-properties-common apt-transport-https curl lsb-release ca-certificates -y
自动脚本导入和安装 GPG 密钥和存储库
curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x
刷新系统的软件包列表
sudo apt update
选择以下 PHP 版本之一为 Nginx 安装 PHP 和 PHP-FPM
sudo apt install php{version} php{version}-fpm php{version}-cli
sudo apt install php7.4 php7.4-fpm php7.4-cli
安装 PHP 扩展
sudo apt install phpx.x-{cli,fpm,curl,mysqlnd,gd,opcache,zip,intl,common,bcmath,imagick,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,dom,memcache}
sudo apt install php7.4-{cli,fpm,curl,mysqlnd,gd,opcache,zip,intl,common,bcmath,imagick,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,dom,memcache}
PHP-FPM 服务开始运行
sudo systemctl start php{version}-fpm
sudo systemctl restart php{version}-fpm
配置 Nginx 服务器块
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php{version}-fpm.sock;
}