Laravel 空白白屏 [英] Laravel blank white screen

查看:50
本文介绍了Laravel 空白白屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 laravel 站点之前可以运行,我最近升级到了 Apache 2.4 和 PHP 5.5.7.

现在我在访问 laravel.mydomain.com 时看到一个白色的空白屏幕,apache 错误日志、路由等中的任何内容都没有像以前那样正常工作.

.htaccess 正在加载,因为当我向/var/sites/laravel/public/.htaccess 插入无效行时得到 500.

这是我的 .htaccess:

$ cat/var/sites/laravel/public/.htaccess<IfModule mod_rewrite.c><IfModule mod_negotiation.c>选项 - 多视图</IfModule>重写引擎开启# 重定向尾部斜杠...重写规则 ^(.*)/$/$1 [L,R=301]# 处理前端控制器...RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [L]

这是我的虚拟主机指令:

DocumentRoot "/var/sites/laravel/public"服务器名称 laravel.mydomain.com<目录/var/sites/laravel/public">允许覆盖所有允许所有人选项 + 索引要求所有授予</目录>

还有 apachectl -S

$/usr/local/apache2/bin/apachectl -S虚拟主机配置:*:* 是 NameVirtualHost默认服务器 mydomain.com (/usr/local/apache2/conf/extra/httpd-vhosts.conf:25)端口 * namevhost mydomain.com (/usr/local/apache2/conf/extra/httpd-vhosts.conf:25)端口 * namevhost laravel.mydomain.com (/usr/local/apache2/conf/extra/httpd-vhosts.conf:34)ServerRoot: "/usr/local/apache2"主文档根:/var/www"主要错误日志:/usr/local/apache2/logs/error_log"互斥体重写映射:using_defaults互斥锁默认:dir="/usr/local/apache2/logs/" 机制=默认PidFile: "/usr/local/apache2/logs/httpd.pid"定义:DUMP_VHOSTS定义:DUMP_RUN_CFG用户:name="daemon" id=1 not_used组:name="daemon" id=1 not_used

解决方案

Apache

此答案 描述或帮助您的情况?升级到 Apache 2.4 伴随着 Apache 配置的一些变化.

Laravel

你是查看 Laravel 的日志还是 Apache 的日志?

自从升级到 Laravel 4.1 以来,当应用程序无法写入日志位置时,我遇到了白屏错误"(WSOD).我总是通过使 Apache 可写的应用程序/存储目录来解决这个问题(组可写为www-data"、apache"或世界可写 - 这取决于您的服务器设置.

Web 服务器用户

在 Ubuntu/Debian 服务器上,您的 PHP 可能以用户www-data"的身份运行.在 CentOS/RedHat/Fedora 服务器上,您的 PHP 可能以apache"用户身份运行.

确保您的文件归运行 PHP 的用户所有:

# Debian/Ubuntu$ sudo chown -R www-data/path/to/laravel/files# CentOS/RedHat/Fedora$ sudo chown -R apache/path/to/laravel/files

<块引用>

请注意,您可能不是以用户 www-data 或 apache 的身份运行.这取决于您的托管和设置!

Laravel 4

# Group Writable (Group, User Writable)$ sudo chmod -R gu+w 应用程序/存储# 全局可写(组、用户、其他可写)$ sudo chmod -R guo+w 应用程序/存储

Laravel 5+(包括 6 个)

# Group Writable (Group, User Writable)$ sudo chmod -R gu+w 存储# 全局可写(组、用户、其他可写)$ sudo chmod -R guo+w 存储###### bootstrap/cache 目录可能也需要写入### 组可写(组,用户可写)$ sudo chmod -R gu+w 引导程序/缓存# 全局可写(组、用户、其他可写)$ sudo chmod -R guo+w 引导程序/缓存

My laravel site was working before, I recently upgraded to Apache 2.4 and PHP 5.5.7.

Now I'm getting a white blank screen when I go to laravel.mydomain.com, nothing in apache error logs, routes and etc. should be fine as it worked before.

.htaccess is loading as I get a 500 when I insert an invalid line to /var/sites/laravel/public/.htaccess.

Heres my .htaccess:

$ cat /var/sites/laravel/public/.htaccess
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Heres my virtual host directive:

DocumentRoot "/var/sites/laravel/public"
ServerName laravel.mydomain.com
<Directory "/var/sites/laravel/public">
    AllowOverride All
    allow from all
    Options +Indexes
    Require all granted
</Directory>

And apachectl -S

$ /usr/local/apache2/bin/apachectl -S
VirtualHost configuration:
*:*                    is a NameVirtualHost
     default server mydomain.com (/usr/local/apache2/conf/extra/httpd-vhosts.conf:25)
     port * namevhost mydomain.com (/usr/local/apache2/conf/extra/httpd-vhosts.conf:25)
     port * namevhost laravel.mydomain.com (/usr/local/apache2/conf/extra/httpd-     vhosts.conf:34)
ServerRoot: "/usr/local/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/usr/local/apache2/logs/error_log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/usr/local/apache2/logs/" mechanism=default
PidFile: "/usr/local/apache2/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="daemon" id=1 not_used
Group: name="daemon" id=1 not_used

解决方案

Apache

Does this answer describe or help your situation? Upgrading to Apache 2.4 come with some changes in Apache configuration.

Laravel

Are you checking Laravel's logs or Apache's logs?

Since upgrading to Laravel 4.1, I've had white screen "errors" (WSOD) when the application could not write to the log location. I've always solved this by making the app/storage directory writable by Apache (either group writable to "www-data", "apache" or world-writable - that depends on your server setup.

Web Server User

On Ubuntu/Debian servers, your PHP may be running as user "www-data". On CentOS/RedHat/Fedora servers, you PHP may be running as user "apache".

Make sure your files are owned by the user that is running PHP:

# Debian/Ubuntu
$ sudo chown -R www-data /path/to/laravel/files

# CentOS/RedHat/Fedora
$ sudo chown -R apache /path/to/laravel/files

Note that you might not be running as user www-data or apache. It depends on your hosting and setup!

Laravel 4

# Group Writable (Group, User Writable)
$ sudo chmod -R gu+w app/storage

# World-writable (Group, User, Other Writable)
$ sudo chmod -R guo+w app/storage

Laravel 5+ (including 6)

# Group Writable (Group, User Writable)
$ sudo chmod -R gu+w storage

# World-writable (Group, User, Other Writable)
$ sudo chmod -R guo+w storage

#####
# The bootstrap/cache directory may need writing to also
##

# Group Writable (Group, User Writable)
$ sudo chmod -R gu+w bootstrap/cache

# World-writable (Group, User, Other Writable)
$ sudo chmod -R guo+w bootstrap/cache

这篇关于Laravel 空白白屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆