Laravel出现了空白的白屏。
Laravel出现了空白的白屏。
我的Laravel站点以前可以正常工作,最近升级到了Apache 2.4和PHP 5.5.7。
现在当我访问laravel.mydomain.example
时,出现了一个白屏,Apache错误日志中没有任何错误,路由等方面应该都没问题,因为以前工作得很好。
.htaccess
可以加载,因为当我在/var/sites/laravel/public/.htaccess
中插入无效行后,会出现500错误。
这是我的.htaccess
:
$ cat /var/sites/laravel/public/.htaccess Options -MultiViews 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]
这是我的虚拟主机指令:
DocumentRoot "/var/sites/laravel/public" ServerName laravel.mydomain.example <Directory "/var/sites/laravel/public"> AllowOverride All allow from all Options +Indexes Require all granted
然后执行apachectl -S:
$ /usr/local/apache2/bin/apachectl -S VirtualHost configuration: *:* is a NameVirtualHost default server mydomain.example (/usr/local/apache2/conf/extra/httpd-vhosts.conf:25) port * namevhost mydomain.example (/usr/local/apache2/conf/extra/httpd-vhosts.conf:25) port * namevhost laravel.mydomain.example (/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
admin 更改状态以发布 2023年5月25日
Apache
这个答案描述或者有助于你的情况吗?升级到Apache 2.4会有一些在Apache配置方面的变化。
Laravel
你是在检查Laravel的日志还是Apache的日志?
自从升级到Laravel 4.1之后,当应用程序无法写入日志位置时,我总是遇到白屏“错误”(WSOD)。我总是通过让app/storage目录可写(组可写为“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