首页 > 解决方案 > Laravel 5 在服务器上显示空白页面但在本地工作

问题描述

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

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

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

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

到目前为止我做了什么:

在这一点上,当它在我的本地笔记本电脑上运行良好时,我不知道它是如何以及为什么突然不起作用的。

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。

标签: phpmysqllaravelnginx

解决方案


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

然后运行,只是肯定的php artisan cache:clear && php artisan config:clear && php artisan config:cache


推荐阅读