# Nginx 配置示例,用于与 PHP-FPM 一起工作
server {
listen 80;
server_name yourdomain.com;
# 网站根目录
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
# PHP 处理配置
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # 根据你的 PHP 版本调整
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# 禁止访问 .htaccess 文件
location ~ /\.ht {
deny all;
}
}
index.php
、index.html
和 index.htm
。.php
结尾的文件,使用 FastCGI 协议将请求传递给 PHP-FPM 进程。include snippets/fastcgi-php.conf
: 包含 FastCGI 的配置片段。fastcgi_pass
: 指定 PHP-FPM 的套接字路径(根据你的 PHP 版本调整)。fastcgi_param SCRIPT_FILENAME
: 设置脚本文件的完整路径。include fastcgi_params
: 包含其他 FastCGI 参数。.htaccess
文件,防止潜在的安全风险。这个配置文件可以帮助你在 Windows 上使用 Nginx 和 PHP-FPM 来运行 PHP 应用程序。请确保你已经正确安装并配置了 Nginx 和 PHP-FPM。
上一篇:php获取昨天的日期
下一篇:php 获取文件后缀
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站