You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

首次搭建Nginx部署Laravel应用 执行nginx -t报log_not_found参数错误如何解决

问题根源

你的Nginx配置存在两处语法错误,均为编辑/复制过程中意外换行拆分参数导致:

  1. 配置第18、19行的log_not_found off被错误拆分为两行,变成不完整的log_not_found of和单独的f;,Nginx无法识别拆分后的非法指令
  2. 配置第28行的$fastcgi_script_name变量被错误拆分为两行,变成$fastcgi_s和单独的cript_name;,导致参数不完整

修正后的完整配置

server {
    listen 80;
    server_name 142.93.111.117;
    root /var/www/colosseo60/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { return 204; access_log off; log_not_found off; }
    location = /robots.txt { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

验证步骤

替换配置文件后重新执行配置测试命令:

sudo nginx -t

如果输出nginx: configuration file /etc/nginx/nginx.conf test is successful即代表配置正常,执行sudo systemctl reload nginx加载新配置即可生效。

内容的提问来源于stack exchange,提问作者gianmarco varrone

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 19:15:07