139

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.example, 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.example
<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.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
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Mico
  • 1,978
  • 2
  • 13
  • 17
  • try and put a blank new install of Laravel in laravel.mydomain.com - does it work then? – Laurence Dec 19 '13 at 12:53
  • HMM,I tried to create project with composer and I'm appearantly missing openssl. Is there any easy way to add it afterwards or do I need to recompile my PHP with current configure options + --with-openssl? – Mico Dec 19 '13 at 13:15
  • 1
    I was having this blank screen problem when moving an already working project onto a staging server. I was getting nowhere with it then I decided to do the same as @the-shift-exchange's suggestion and create a fresh install of Laravel, then I found the problem pretty quickly; the staging server was running an outdated version of PHP. Laravel requires at least PHP v5.4.0. Thought I'd mention it incase anyone else had the same trouble. – igneosaur Sep 25 '14 at 12:08
  • Check the memory limit isn't being hit - this has caused WSOD for me before in Laravel 4 – Edmunds22 Aug 08 '19 at 13:45
  • Just another data point - I hit this on an an app deployed to Kubernetes, using NFS to mount the web files. Due to very slow NFS performance, it seemed Laravel was failing to cache the views within a reasonable amount of time. PHP-FPM was returning an empty response. Fixed by manually removing all views and re-caching them. – Joe Niland Nov 18 '19 at 03:57

35 Answers35

236

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
fideloper
  • 12,213
  • 1
  • 41
  • 38
  • 10
    Seems like it was a permission problem. chmodding the laravel directory made it work. – Mico Dec 19 '13 at 15:05
  • 4
    @fideloper This answer really saved my day. Was getting WSOD, and nothing showing up in logs anywhere. chmodding the app/storage took care of it. I tip my virtual hat to you! – Tim Habersack Dec 23 '13 at 22:37
  • Yeah thank you for this really saved me here. I was getting a X-pad: avoid browser bug in my http response and I thought it was that – Simon Bennett Jan 16 '14 at 22:36
  • Had the same problem on Nginx. Adding write-permissions to this folder solved the problem for me. – Giel Berkers Feb 25 '14 at 09:37
  • 5
    Permission on storage folder solved my such issue. But why laravel doesn't show permission issue on browser? – Musa Apr 03 '14 at 08:03
  • It's likley something to do with timing - Logging errors to the log happens after Laravel turns off displaying raw PHP errors but before it's able to turn on error handling (converting all errors to exceptions and displaying the exceptions gracefully). It's a "chicken and the egg" type problem. – fideloper Apr 03 '14 at 15:44
  • 4
    This fixed the problem for me too.... would never have found this on my own. I agree it would be best if there was some sort of error message displayed rather than the "white screen of death". – dusty909 Apr 06 '14 at 18:17
  • Don't forget +x for your directories. Somehow that got lost on my laravel/bootstrap folder. – EpicVoyage Aug 10 '14 at 19:41
  • On Digital Ocean Ubuntu 14.04 Apache, later works fine. – achintverma Apr 09 '15 at 00:23
  • The `chmod` command solved my problem. I'm using Laravel 5.4 on Ubuntu 16.04 – Rouhollah Mazarei Apr 16 '17 at 07:54
  • Saved me as well. Oddly though, this wasn't after any sort of upgrade (PHP version or otherwise) -- it seemed to happen randomly on a homestead local copy of laravel. Why would the storage directory's permissions change seemingly on a whim? – Ben Wilson Jun 01 '17 at 01:43
  • This works to me. I was getting this error becouse i've cloned the machine and do not re run this commands. – Rodrigo Xavier Jul 31 '17 at 15:27
  • This did it: sudo chown -R www-data – Patrick Oct 26 '21 at 18:52
  • For me everything worked fine and suddenly the website shows blank page, permissions to the folders are already given. – Shamshad Zaheer Jul 05 '22 at 20:37
66

An update to fideloper's answer for Laravel 5 and its new file structure is:

$ sudo chmod -R o+w storage/
EddardOmeka
  • 795
  • 5
  • 11
33

Try this, in the public/index.php page

error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set("display_errors", 1);
CG_DEV
  • 788
  • 7
  • 7
  • This was actually what I needed because for some reason on the server work has (Plesk) it was not logging anything to the error log and nothing to the laravel log, adding this showed me that it was actually a missing file that was causing my blank 500 screen, thanks a bunch! – Someone Aug 24 '16 at 07:54
  • I had white screen also and no errors at all. All permission and everything were perfect. This answer helped me to actually see what is going on. Thanks. – S.I. Nov 08 '16 at 12:41
  • have messed up with this issue since yesterday. Beyond folders' permission in my case this check was reported that the server hasn't extracted all folders inside vendor folder !? What a mystery.... Really a good approach.Useful for public servers without low access. – CodeToLife Jun 26 '20 at 07:06
  • my case it does not work still showing strange blank screen – Balaji May 17 '21 at 17:13
  • This gave me actionable errors, I was missing `composer install` – wruckie Dec 20 '22 at 04:01
  • Thanks to this I was able to find that my PHP version was wrong and had to change it on my shared hosting. – Dave Jan 29 '23 at 22:01
28

The following steps solved blank white screen problem on my Laravel 5.

  • Go to your Laravel root folder
  • Give write permission to bootstrap/cache and storage directories

sudo chmod -R 777 bootstrap/cache storage

  • Rename .env.example to .env
  • Generate application key with the following command in terminal/command-prompt from Laravel root:

php artisan key:generate

This will generate the encryption key and update the value of APP_KEY in .env file

This should solve the problem.

If the problem still exists, then update config/app.php with the new key generated from the above artisan key generate command:

'key' => env('APP_KEY', 'SomeRandomString'),

to

'key' => env('APP_KEY', 'KEY_GENERATED_FROM_ABOVE_COMMAND'),

Mukesh Chapagain
  • 25,063
  • 15
  • 119
  • 120
15

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);
Hassan Gilak
  • 691
  • 9
  • 14
11

I have also one more option why blank page issue may occur. If you are on production mode and if you cached your config files by php artisan (config:cache), try to delete cache file executing:

php artisan config:clear

or delete it manualy (bootstrap/cache/config.php)

Boris Tetřev
  • 278
  • 1
  • 4
  • 9
10

In general if Laravel showing you white page without error first thing looking in the .evn file for error my wrong was.

The problem was in .env file in APP_NAME

Just i replaced

APP_NAME=My Project Name 

to

APP_NAME="My Project Name"
Abd Abughazaleh
  • 4,615
  • 3
  • 44
  • 53
  • This is the answer that saved my huge time I believe! ===> "In general if Laravel showing you white page without error first thing looking in the .evn file for error my wrong was." – Shamim Oct 26 '22 at 17:17
8

Running this command solved it for me:

php artisan view:clear

I guess a blank error page was some how cached. Had to clear the caches.

Andrew
  • 18,680
  • 13
  • 103
  • 118
7

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.

Vikash
  • 219
  • 5
  • 13
  • 1
    Step (2) was missing from my installation. I had cloned the project thinking it had all of the necessary files in the directory for it to work out of the box. I still had trouble, but this was a crucial step. – Jonathan Hickman Oct 04 '16 at 02:41
7

Facing the blank screen in Laravel 5.8. Every thing seems fine with both storage and bootstrap folder given 777 rights. On

php artisan cache:clear

It shows the problem it was the White spaces in App Name of .env file

saad
  • 1,354
  • 1
  • 14
  • 21
6

It took me almost 2 hour to solve this problem. These are reasons find out in answers:

  • Remove space in .env file
  • Rewrite .htaccess
  • chmod 777 storage / bootstrap folder
  • Remove vendor folder and run composer install again
  • Restart apache/nginx server
  • php artisan view:clear
  • php artisan cache:clear
  • php artisan route:clear

I tried everything but it still doesn't working.

Turn out the default port for apache/nginx server is not PORT 80. When you installed webpack, it may be changed because of corrupting with Skype or system services. So instead of access to yoursite.test on localhost, you must use yoursite.test:85 which 85 is the default PORT of apache/nginx server.

user16806454
  • 391
  • 3
  • 8
5

I was struggling with a similar issue on a CentOS server. Using php artisan serv and accessing it through port 8000 on the local machine worked fine but could not get my remote machines to load a particular view. I could return strings fine, and some views were loading. Chased my tail on permissions for a while before I finally realized it was an SELinux issue. I just set it from enforce to permissive and it worked. Hope that helps someone else out there that may be encountering the same issue.

setenforce permissive
Kamkat86
  • 85
  • 2
  • 4
5

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.

qskane
  • 481
  • 4
  • 16
  • 1
    I lost an entire day off to this issue. This is answer that finally saved me. I wish I could give you more than an up vote. Thank you! – Miles Aug 05 '19 at 05:19
4

Blank screen also happens when your Laravel app tries to display too much information and PHP limits kick in (for example displaying tens of thousands of database records on a single page). The worst part is, you won't see any errors in the Laravel logs. You probably won't see any errors in the PHP FPM logs as well. You might find errors in your http server logs, for example nginx throws something like FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of XXX bytes exhausted.

Short tip: add ->limit(1000) where 1000 is your limit, on your query object.

f055
  • 1,190
  • 12
  • 23
4

It shows the problem it was the White spaces in App Name of .env file

2

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

gvsrepins
  • 1,687
  • 2
  • 17
  • 20
2

Another thing that may cause the WSOD is missing the 'return' keyword, as in:

return View::make('yourview');

as opposed to

View::make('yourview');

emragins
  • 4,607
  • 2
  • 33
  • 48
2

use this .htaccess to solve

Options +ExecCGI
addhandler x-httpd-php5-cgi .php
Options -MultiViews
DirectoryIndex index.php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^ index.php [L]
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Dave
  • 3,073
  • 7
  • 20
  • 33
Kaushik Dey
  • 77
  • 1
  • 8
2

There might be a lot of reasons behind the blank screen without errors. I have faced this problem many times whenever I want to upload laravel project in shared hosting.

Reason: Incorrect PHP Version

In my case, issue was because of incorrect php version. I had php 7.1 version in local computer where as in shared hosting cpanel, there was php 5.6 version. Switching up the version from 5.6 to 7.1 worked for me.

You can change php version in cpanel from multiphp manager available in cpanel home page.

Sagar Gautam
  • 9,049
  • 6
  • 53
  • 84
2

Make sure that there are no typos in your .env file. This was the cause of a blank screen with me.

Nothing got logged to screen nor logfiles or nginx logs. Just a blank screen.

Evert E.
  • 61
  • 3
1

Sometimes it's because laravel 5.1 require PHP >= 5.5.9. Update php will solve the problem.

Kevin
  • 795
  • 2
  • 9
  • 21
1

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

gorodezkiy
  • 3,299
  • 2
  • 34
  • 42
1

I also faced same issue after doing composer update

I tried installing composer required monolog/monolog too but didn't work.

Then I removed the /vendor directory and ran composer install and worked as per normal.

basically it must have reverted my monolog and other stable packages version back to previous. so better not to composer update

what I noticed comparing both the /vendor folders and found those classes files under /vendor/monolog/monolog/src/Handler were missing after composer updated.

Amit Shah
  • 7,771
  • 5
  • 39
  • 55
1

Sometimes in route.php you may have

Route::get('/{id}', 'Controller@show'..

written before

Route::get('/add', 'Controller@add'..

It can be empty method Controller::show() when you begin to develop your controller from scratch. In this case you will get empty blank page when requesting /add url. It happens because the request was handled by /{id} route, and its method returns nothing.

Just try to place /add route before /{id}

0

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

Hernan
  • 69
  • 1
  • 3
0

Reason can be Middleware if you forget to put following code to the end of handle function

return $next($request);
Farid Movsumov
  • 12,350
  • 8
  • 71
  • 97
0

I was also getting same error when I start first time on laravel + Ubuntu 14.04 I just right click on bootstrap and storage folder >>> properties >>>permission>> Others Access >>> change it to "Create and delete files" Change permission for enclosed files

Thank you

0

Got this from the Laravel forums, but if you recently upgraded Laravel versions AND PHP versions AND are running nginx, make sure you have changed your nginx configuration file to reflect the new PHP version. For instance:

In your nginx site config file (here: /etc/nginx/sites-available), change

fastcgi_pass unix:/var/run/php5-fpm.sock;

to

fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;

Ben Wilson
  • 2,271
  • 3
  • 26
  • 35
0

I have same issue. I already change chmod folder for Storage folder. fill database settings in .env, but didn't fix the problem. I used Laravel 5.5 and I used PHP 5.6, to fix it I went to (cpanel->PHP Selector) and I changed to PHP 7.1 And the issue is done.

Abed Putra
  • 1,153
  • 2
  • 17
  • 37
0

On normal cases errors should be logged Unless

Script can't write to log file

  • check it's path
  • permissions

Or error occurred on higher level check app server logs like Appache || Nginx

Or it's resources limits Like PHP ini settings

memory_limit
max_input_time
max_execution_time

Or OS limit's and so on

Bdwey
  • 1,813
  • 1
  • 16
  • 18
0

In addition to Permission problems in storage and cache folder and php version issues, there could be another reasons to display blank page without any error message.

For example, I had a redeclare error message without any log and with blank white page. There was a conflict between my own helper function and a vendor function.

I suggest as a starting point, run artisan commands. for example:

php artisan cache:clear

If there was a problem, it will prompted in terminal and you've got a Clue and you can google for the solution.

Khalil Laleh
  • 1,168
  • 10
  • 19
0

I hit this problem when I tried to run a Laravel 5.8 app on my server, uploading from local development using Vagrant Homestead. After a while I figured out that the dev subdomain on the live server I was running was somehow set to PHP 5.6.

cPanel > MultiPHP Manager > Set to PHP 7.2

fixed this for me. Hope this might help someone.

Inigo
  • 8,110
  • 18
  • 62
  • 110
0

in my case, the BLANK WHITE SCREEN issue was as simple as a typo or wrong character on the env file. I was implementing socialite, so when I was setting up the .env credentials for Google+ like this:

G+_CLIENT_ID = Your G+ Client ID
G+_CLIENT_SECRET = Your G+ Client secret
G+_REDIRECT = 'http://localhost:8000/callback/google'

But, the .env file can't use the '+' sign, so I have to make this correction:

GOOGLE_CLIENT_ID = Your G+ Client ID
GOOGLE_CLIENT_SECRET = Your G+ Client secret
GOOGLE_REDIRECT = 'http://localhost:8000/callback/google'

I hope this help you find a dumb error...

absolutkarlos
  • 570
  • 1
  • 9
  • 22
-2

In my case, restarting apache fixed the problem. for Ubuntu / Debian:

sudo service apache2 restart
-2

This changes works for my localhost Ubuntu server 14.xx setting

# Apply all permission to the laravel 5.x site folders     
$ sudo chmod -R 777 mysite

Also made changes on site-available httpd setting Apache2 settings

Add settings:

Options +Indexes +FollowSymLinks +MultiViews
Require all granted
Community
  • 1
  • 1
syyu
  • 409
  • 7
  • 10
  • In a web server, it is not advisable to set ‘777’ permission for your files and folders as it allows anyone to add malicious code to your server. However, in some cases, you will need to set the 777 permissions before you can upload any file to the server (For example, uploading images in WordPress) https://www.maketecheasier.com/file-permissions-what-does-chmod-777-means/ – Shannon Matthews Nov 08 '16 at 21:44