【问题标题】:Laravel 500 error when using with nginx与 nginx 一起使用时 Laravel 500 错误
【发布时间】:2016-07-09 10:35:38
【问题描述】:

我已经尝试了很多配置设置让 nginx 与 laravel 一起使用,但没有一个可以。我的网页上不断收到 500 错误。

example.com 当前无法处理此请求。

server {
    listen   _:80;
    server_name  example.com;

    root "C:\Users\Administrator\Google Drive\projects\laravel";
    index index.php index.html;

    log_not_found off;
    charset utf-8;

    access_log  logs/cdn.example.com-access.log ;

    location ~ /\. {deny all;}

    location ~ \.css {
        add_header  Content-Type    text/css;
    }

    location ~ \.js {
        add_header  Content-Type    application/x-javascript;
    }

    location / {
        include mime.types;
    }

    location = /favicon.ico {
    }

    location = /robots.txt {
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9054;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

我对 laravel 非常陌生,对 nginx 也很陌生,我的所有 laravel 文件都在我刚刚从 http://localhost:8000 开发服务器移动的文档根目录中。我怎样才能让它活起来并让它与 nginx 一起工作?

【问题讨论】:

  • 你确定它应该是 example.com 吗?
  • 谷歌搜索“Laravel 500 错误代码”会导致这里出现。原因之一也是 PHP 版本。就我而言,我有一台运行 PHP 5.3 的旧服务器,我尝试在它上面安装 Laravel。

标签: php laravel nginx laravel-5


【解决方案1】:

我可以在您的帖子中看到错误的配置。您需要正确设置您的网络服务器。您应该将public 目录设置为根目录,并设置storage 文件夹的写入权限。

所以,改变这个:

root "C:\Users\Administrator\Google Drive\projects\laravel";

到这里:

root "C:\Users\Administrator\Google Drive\projects\laravel\public";

然后重新启动您的网络服务器。

【讨论】:

  • 我已经更改并重新启动了 nginx,它仍然会抛出 500 错误。虽然在我的 url 添加 /public 时会抛出 404 not found nginx 页面。
  • 您是否设置了存储文件夹的写入权限?如果没有转到根目录并使用chmod -R 777 storage 命令(如果您使用的是 Linux 服务器)。另外,在日志文件中查找错误信息,会有很大帮助。
  • 存储文件夹有权限,我在访问我的域时仍然遇到同样的错误,但是在添加 /public 时显示 404 未找到。错误日志中没有错误!我也在使用 Windows R2 服务器
  • public 添加到 URL 是错误的,不要这样做。如果您的日志为空,请在您的.env 文件中将调试更改为APP_DEBUG=true
  • 它已经设置为 true,我正在检查我的 nginx 日志我是要检查 laravel 日志吗?
猜你喜欢
  • 2020-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-11
  • 1970-01-01
  • 2019-08-25
  • 2014-08-27
  • 1970-01-01
相关资源
最近更新 更多