为了账号安全,请及时绑定邮箱和手机立即绑定

Laravel黑屏的问题

Laravel黑屏的问题

PHP
一只名叫tom的猫 2019-11-23 10:56:57
我的laravel站点以前可以工作,最近我升级到Apache 2.4和PHP 5.5.7。现在,当我进入laravel.mydomain.com时,我得到一个白色的空白屏幕,apache错误日志,路由等中的任何内容都应该像以前一样正常。当我在/var/sites/laravel/public/.htaccess中插入无效行时,得到500,.htaccess正在加载。这是我的.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} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [L]这是我的虚拟主机指令: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>和apachectl -S$ /usr/local/apache2/bin/apachectl -SVirtualHost 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_defaultsMutex default: dir="/usr/local/apache2/logs/" mechanism=defaultPidFile: "/usr/local/apache2/logs/httpd.pid"Define: DUMP_VHOSTSDefine: DUMP_RUN_CFGUser: name="daemon" id=1 not_usedGroup: name="daemon" id=1 not_used
查看完整描述

3 回答

?
阿晨1998

TA贡献2037条经验 获得超6个赞

阿帕奇

这个答案是否描述或帮助了您的情况?升级到Apache 2.4会对Apache配置进行一些更改。


拉拉韦尔

您在查看Laravel的日志还是Apache的日志?


自从升级到Laravel 4.1之后,当应用程序无法写入日志位置时,我遇到了白屏“错误”(WSOD)。我总是通过使app / storage目录可被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 app/storage


# World-writable (Group, User, Other Writable)

$ sudo chmod -R guo+w app/storage

Laravel 5+(包括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


查看完整回答
反对 回复 2019-11-23
?
MMTTMM

TA贡献1869条经验 获得超4个赞

当我刚接触Linux时,通常会在我的Laravel项目中发现此错误。白色错误表示错误,它可能存在某些权限问题或错误。


您只需要遵循两个步骤,就能像冠军般工作:)


(1)给予许可。从项目的根目录运行这些命令


(a) sudo chmod 777 -R storage

(b) sudo chmod bootstrap/cache

(2)如果您克隆了项目或从github提取了项目,请运行


composer install

(3)正确配置.env文件,您的项目将运行。


查看完整回答
反对 回复 2019-11-23
  • 3 回答
  • 0 关注
  • 354 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信