Laravel blank white screen

2019-01-03 07:58发布

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

25条回答
女痞
2楼-- · 2019-01-03 08:20

for anyone who get blank page even after making storage accessible for displaying errors put these two lines at first lines of public/index.php to see what is happening at least. for me this error was there :Class 'PDO' not found in /var/www/***/config/database.php on line 16

error_reporting(E_ALL);
ini_set('display_errors', 1);
查看更多
Summer. ? 凉城
3楼-- · 2019-01-03 08:21

When I was new to Linux.I usually found this error with my Laravel Project. White errors means error, It may have some permission issue or error.

You just have to follow two steps, and will work like champ :)

(1) Give the permission. Run these command from root directory of your project

(a) sudo chmod 777 -R storage
(b) sudo chmod bootstrap/cache

(2) If you cloned the project or pulled from github then run

composer install

(3) Configure your .env file properly, and your project will work.

查看更多
甜甜的少女心
4楼-- · 2019-01-03 08:22

In my case , I have installed laravel many times, and I am sure that the folder write permission has been correctly given.

Like most of the answers above :

sudo chmod 777 -R storage bootstrap

The mistake is that my nginx configuration comes from the official documentation.

I only modified the domain name after copying ,then I got a blank page. I tried restarting nginx and php-fpm,but not work for me.

Finally, I added this line configuration to solve the problem.

location ~ \.php$ {

    # same as documentation ...

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

I hope I can help others.

查看更多
疯言疯语
5楼-- · 2019-01-03 08:24

Other problem with the same behavior is use Laravel 3 with PHP 5.5.x. You have to change some laravel function's name "yield() because is a reserved word in php 5.5

查看更多
一夜七次
6楼-- · 2019-01-03 08:26

I have some issues to setup it in a Vagrant machine. Whats really works for me was execute a:

chmod -R o+w app/storage/

from inside the Vagrant machine.

Reference: https://laracasts.com/lessons/vagrant-and-laravel

查看更多
孤傲高冷的网名
7楼-- · 2019-01-03 08:26

Strange for me, but in my case I had to clear the laravel's cache to solve the issue.

查看更多
登录 后发表回答