【问题标题】:Nginx error 403 on laravel app - Centos 7laravel 应用程序上的 Nginx 错误 403 - Centos 7
【发布时间】:2018-02-22 01:13:41
【问题描述】:

我在 centos 7 上运行的 nginx 服务器上遇到了这个烦人的 403 禁止错误
你可以自己检查 http://zargold.com

nginx.conf:

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  zargold.com;
    root         /home/zargol/public_html/public;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    #location / {
    #    try_files $uri $uri/ /index.php;
    #}

location ~ \.php$ {
    #try_files $uri /index.php =404;
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    root /home/zargol/public_html/public;
}
    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

我已经为此工作了好几天,它没有得到修复!
注意:我在here 中使用过说明
更新
现在发生了一件非常奇怪的事情。
我在这个 vps ip 地址上设置了两个域,另一个出现了不同的错误(502 Bad Gateway) http://zar7.com

【问题讨论】:

  • 您检查过文件所有权和权限吗?
  • 是的,权限在 777
  • 那个根是正确的? (问是因为 zargold/zargol)
  • 您评论了 location / { } 块,但没有评论内部的 try_files,请尝试也将其评论或取消评论整个块
  • @kerbholz 是的,没关系

标签: php laravel nginx


【解决方案1】:

您尚未定义index 指令,因此nginx 使用默认值index index.html

如果根目录下没有index.html文件,nginx会返回403响应。

对于 Laravel,您可能应该使用:

index index.php;

请参阅this document 了解更多信息。

【讨论】:

  • 您有两个root 语句。如果它们不相同,您将收到 404 响应。
  • 他们不一样吗?
  • 此外,考虑到我删除了第二个,我仍然收到错误
猜你喜欢
  • 2016-05-09
  • 2019-01-16
  • 1970-01-01
  • 2018-09-13
  • 2020-03-03
  • 1970-01-01
  • 1970-01-01
  • 2016-08-04
  • 1970-01-01
相关资源
最近更新 更多