laravel nginx怎么也配置不通,求高人指点?

访问abc.com时nginx日志显示如下错误

2023/02/18 11:28:38 [crit] 21879#0: *24748177 stat() "/disk_1/new/laravel/demo/public/" failed (13: Permission denied), client: 192.69.85.177, server: abc.com, request: "GET / HTTP/1.1", host: "abc.com"
2023/02/18 11:28:38 [crit] 21879#0: *24748177 stat() "/disk_1/new/laravel/demo/public/" failed (13: Permission denied), client: 192.69.85.177, server: abc.com, request: "GET / HTTP/1.1", host: "abc.com"
2023/02/18 11:28:38 [error] 21879#0: *24748177 open() "/disk_1/new/laravel/demo/public/favicon.ico" failed (13: Permission denied), client: 192.69.85.177, server: abc.com, request: "GET /favicon.ico HTTP/1.1", host: "abc.com", referrer: "http://abc.com/"

nginx配置如下:

server {
    listen 80;
    server_name abc.com;
    root /disk_1/new/laravel/demo/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 { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    #error_page 404 /index.php;

    include /usr/local/nginx/conf/fastcgi.conf;

    location ~ \.php$ {
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        #fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
    error_log /www/logs/abc_err.log;
}

求大神指教

阅读 2.2k
2 个回答

出错代码里不是写了吗 Permission denied 权限问题啊,
检查 Nginx 的启动用户,和当前目录的用户和权限,

检查php-fpm的用户和PHP文件的用户, 看有没有访问权限.

另外 include fastcgi_params; 这句改成 include fastcgi.conf;

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题