# Nginx 配置文件示例,用于处理 PHP 请求
server {
listen 80;
server_name yourdomain.com;
# 网站根目录
root /var/www/yourdomain.com/html;
index index.php index.html index.htm;
# 处理 PHP 文件的 location 块
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# 将 PHP 请求传递给 PHP-FPM
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # 根据你的 PHP 版本调整此路径
# 设置必要的 FastCGI 参数
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# 防止访问 .htaccess 文件
location ~ /\.ht {
deny all;
}
}
index.php、index.html 和 index.htm。.php 结尾的文件,并将这些请求传递给 PHP-FPM 进行处理。.htaccess 文件,防止潜在的安全风险。上一篇:php获取ip
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站