Laravel blank white screen
PhpApacheFrameworksLaravelLaravel 4Php Problem Overview
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
Php Solutions
Solution 1 - Php
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
Solution 2 - Php
An update to fideloper's answer for Laravel 5 and its new file structure is:
$ sudo chmod -R o+w storage/
Solution 3 - Php
The following steps solved blank white screen problem on my Laravel 5.
- Go to your Laravel root folder
- Give write permission to
bootstrap/cache
andstorage
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'),
Solution 4 - Php
Try this, in the public/index.php page
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set("display_errors", 1);
Solution 5 - Php
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);
Solution 6 - Php
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)
Solution 7 - Php
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.
Solution 8 - Php
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.
Solution 9 - Php
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
Solution 10 - Php
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
Solution 11 - Php
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.
Solution 12 - Php
It shows the problem it was the White spaces in App Name of .env file
Solution 13 - Php
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"
Solution 14 - Php
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 runcomposer 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.
Solution 15 - Php
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</sub>
Solution 16 - Php
Another thing that may cause the WSOD is missing the 'return' keyword, as in:
return View::make('yourview');
as opposed to
View::make('yourview');
Solution 17 - Php
Sometimes it's because laravel 5.1 require PHP >= 5.5.9. Update php will solve the problem.
Solution 18 - Php
Strange for me, but in my case I had to clear the laravel's cache to solve the issue.
Solution 19 - Php
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.
Solution 20 - Php
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.
Solution 21 - Php
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>
Solution 22 - Php
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.
Solution 23 - Php
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}
Solution 24 - Php
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.
Solution 25 - Php
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
Solution 26 - Php
Reason can be Middleware
if you forget to put following code to the end of handle
function
return $next($request);
Solution 27 - Php
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
Solution 28 - Php
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;
Solution 29 - Php
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.
Solution 30 - Php
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
Solution 31 - Php
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.
Solution 32 - Php
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.
Solution 33 - Php
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...
Solution 34 - Php
In my case, restarting apache fixed the problem. for Ubuntu / Debian:
sudo service apache2 restart
Solution 35 - Php
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