php - Laravel 5 在服务器上显示空白页面但在本地工作
问题描述
从今天开始,当我从笔记本电脑上的本地开发环境将更新上传到生产服务器时,我遇到了一个问题。
当我尝试访问一个页面时,它完全是空白的。我没有碰任何东西——我像往常一样上传新文件,这一直有效。
我还可以完美地访问我的资产,例如图像、js 和 css。当我使用 Steam 登录时,我的身份验证中间件正在工作,它会将我重定向到通过 Steam 登录。
我记得在它崩溃之前做了什么:
- 上传了我的文件
- 跑了
composer dumpautoload
- 跑了
php artisan cache:clear
到目前为止我做了什么:
- 检查了我的 NGINX/PHP/MySQL 错误日志。没有什么。
- 检查了laravel日志,也没有。
- 确保 PHP、NGINX 和 Mysql 正在运行。
- 确保 php、nginx 和 mysql 是最新的。
- 生成了新密钥
- 仔细检查了我的 .env ,所以它是有效的。
- 作曲家更新
- chmodded 我的目录(即使在空白页之前我对此没有任何问题)。
在这一点上,当它在我的本地笔记本电脑上运行良好时,我不知道它是如何以及为什么突然不起作用的。
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
文件,尤其是 vars APP_KEY
(php artisan key:generate) 和APP_URL
.
然后运行,只是肯定的php artisan cache:clear && php artisan config:clear && php artisan config:cache
。
推荐阅读
- java - Java - 如何正确获取和添加 cookie 以请求标头?
- geolocation - 如何通过服务器端的 IP 地址估计用户位置?
- python - 如何使用列表推导替换字符串中的字符?
- php - keycloak登录后如何获取用户信息
- python - 为每 1000 的倍数重置 Pandas Cumsum
- command-line - dotnet——环境文档?
- grouping - 如何遍历 Group-Object 的结果
- django - docker-compose + django + redis - 连接到 127.0.0.1:6379 时出现错误 111。拒绝连接
- html - 我需要帮助查找该函数的名称
- python - 为什么这两个代码打印不同的东西?