1 安装php-fpm
apt update
apt-get install php-fpm
#配置php-fpm服务启动
systemctl enable php8.1-fpm
systemctl start php8.1-fpm
#查看服务
systemctl status php8.1-fpm
#查看版本
root@iZbp1g7fmjea77vsqc5hmmZ:~# php -v
PHP 8.1.2-1ubuntu2.18 (cli) (built: Jun 14 2024 15:52:55) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologieswith Zend OPcache v8.1.2-1ubuntu2.18, Copyright (c), by Zend Technologies
2 nginx 安装
sudo apt update
sudo apt-get install nginx
#配置nginx服务启动
sudo systemctl restart nginx
sudo systemctl enable nginx
3 配置nginx
vim /etc/nginx/sites-available/defaultroot /data/www/html;location ~ \.php$ {include snippets/fastcgi-php.conf;fastcgi_pass unix:/run/php/php8.1-fpm.sock;}
4 测试文件
#vim /data/www/html/index.php
<?php
phpinfo();
?>
5 访问测试页面