如何在 Nginx 中启动 php?在 nginx 中启动 php 的步骤:1. 安装 php;2. 安装 php-fpm;3. 配置 nginx 虚拟主机以使用 php-fpm。
如何启动 nginx 中的 PHP
简要回答:
在 nginx 中启动 PHP 的步骤:
详细说明:
立即学习“PHP免费学习笔记(深入)”;
1. 安装 PHP:
使用以下命令安装 PHP:
sudo apt-get update sudo apt-get install php7.4-fpm
2. 安装 PHP-FPM:
使用以下命令安装 PHP-FPM:
sudo apt-get install php7.4-fpm
3. 配置 nginx 虚拟主机:
打开虚拟主机配置文件(例如,/etc/nginx/sites-available/example.com),并添加以下配置:
location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
其中:
保存并退出配置文件。
重启 nginx:
sudo systemctl restart nginx
PHP 现在应该在 nginx 中启动并运行。
以上就是nginx怎么启动php的详细内容,更多请关注中国大学网其它相关文章!