【问题标题】:Laravel 5 shows blank page on server but works locallyLaravel 5 在服务器上显示空白页面但在本地工作
【发布时间】:2019-12-19 10:56:33
【问题描述】:

从今天开始,我从笔记本电脑上的本地开发环境将更新上传到生产服务器时遇到了问题。

当我尝试访问一个页面时,它完全是空白的。我没有碰任何东西 - 我在上传新文件时一直这样做,这一直有效。

我还可以完美地访问我的资产,例如图像、js 和 css。当我使用 Steam 登录时,我的身份验证中间件正在工作,它会将我重定向到通过 Steam 登录。

我记得在它崩溃之前做了什么:

  • 上传了我的文件
  • composer dumpautoload
  • php artisan cache:clear

到目前为止我做了什么:

  • 检查了我的 NGINX/PHP/MySQL 错误日志。什么都没有。
  • 检查 laravel 日志,也没有。
  • 确保 PHP、NGINX 和 Mysql 正在运行。
  • 确保 php、nginx 和 mysql 是最新的。
  • 生成了新密钥
  • 仔细检查了我的 .env,所以它是有效的。
  • 作曲家更新
  • 修改了我的目录(尽管在空白页之前我对此没有任何问题)。

此时我不知道它是如何以及为什么突然无法正常工作的,而它在我的本地笔记本电脑上工作得非常好。

nginx 配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name example.com;

    proxy_set_header X-Forwarded-For $remote_addr;

    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    root /var/www/preview/example/public;

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

    charset utf-8;

    index index.html index.htm index.php;

    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; }

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

        #auth_basic "Restricted Content";
        #auth_basic_user_file /etc/nginx/.htpasswd;
    }

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

    server_name hsbuilds.com;
    ssl    on;
    ssl_certificate /home/hsbuilds/src/hsbuilds/example.com.chained.crt;
    ssl_certificate_key /home/hsbuilds/src/example.com/example.com.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

    #location / {
    #   proxy_pass http://example.com:8000;
    #   proxy_set_header X-Forwarded-For $remote_addr;
    #}
}

编辑:在 chrome 中检查网络标签时,页面返回代码 200。

【问题讨论】:

  • 如果您没有收到任何错误,这听起来像是 .env 文件中的错误(不需要的字符)。 Laravel 退出 500 但如果 .env 无效则没有错误
  • 查看storage/logs中的日志,看看是否有异常发生。
  • @solarc 没有发生任何错误,而且我从来没有用更新触及过我的 .env 文件,因为它在此之前工作过(但我已经验证它是有效的)
  • 有nginx日志吗?
  • 您是否尝试在您的.env 中设置APP_DEBUG=true 以查看任何警告/错误?

标签: php mysql laravel nginx


【解决方案1】:

首先,检查.env 文件,尤其是变量APP_KEY(php artisan key:generate) 和APP_URL

然后运行,确定php artisan cache:clear && php artisan config:clear && php artisan config:cache

【讨论】:

  • 我再次这样做只是为了仔细检查,但没有帮助。
  • 你在使用 docker 吗?
  • 同样在 env 有效之后 - 运行 composer update。如果是 docker - 检查 docker 的 apache (nginx) 中的日志
  • 不,我没有使用 docker。我还运行了 composer update ,可悲的是没有帮助。而且所有日志都是空的。
  • 暂时没有想法 - 任何地方的任何错误(服务器是否有效?),但看起来像是切换到 docker 的原因:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-06-27
  • 2016-04-06
  • 2016-03-30
  • 2020-05-12
  • 2016-03-25
  • 1970-01-01
  • 2018-08-10
相关资源
最近更新 更多