Mico
Mico

Reputation: 2009

Laravel blank white screen

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

Upvotes: 141

Views: 257204

Answers (30)

user16806454
user16806454

Reputation: 421

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.

Upvotes: 6

Abd Abughazaleh
Abd Abughazaleh

Reputation: 5535

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"

Upvotes: 11

Evert E.
Evert E.

Reputation: 61

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.

Upvotes: 2

Chintan Hingrajia
Chintan Hingrajia

Reputation: 329

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

Upvotes: 4

Илья Алисов
Илья Алисов

Reputation: 434

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}

Upvotes: 1

fideloper
fideloper

Reputation: 12293

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

Upvotes: 240

absolutkarlos
absolutkarlos

Reputation: 610

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...

Upvotes: 0

Sagar Gautam
Sagar Gautam

Reputation: 9369

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.

Upvotes: 2

saad
saad

Reputation: 1364

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

Upvotes: 7

Kaushik Dey
Kaushik Dey

Reputation: 77

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>

Upvotes: 2

Inigo
Inigo

Reputation: 8685

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.

Upvotes: 0

Amit Shah
Amit Shah

Reputation: 8179

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.

Upvotes: 1

Boris Tetřev
Boris Tetřev

Reputation: 287

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)

Upvotes: 11

qskane
qskane

Reputation: 521

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.

Upvotes: 5

f055
f055

Reputation: 1190

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.

Upvotes: 4

Andrew
Andrew

Reputation: 20081

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.

Upvotes: 8

Khalil Laleh
Khalil Laleh

Reputation: 1238

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.

Upvotes: 0

Bdwey
Bdwey

Reputation: 2003

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

Upvotes: 0

Abed Putra
Abed Putra

Reputation: 1215

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.

Upvotes: 0

Ben Wilson
Ben Wilson

Reputation: 2676

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;

Upvotes: 0

user1846871
user1846871

Reputation: 68

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

Upvotes: 0

gorodezkiy
gorodezkiy

Reputation: 3419

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

Upvotes: 1

Mukesh Chapagain
Mukesh Chapagain

Reputation: 25968

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'),

Upvotes: 29

Kamkat86
Kamkat86

Reputation: 85

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

Upvotes: 5

Hassan Gilak
Hassan Gilak

Reputation: 699

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);

Upvotes: 15

Vikash
Vikash

Reputation: 219

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.

Upvotes: 7

Farid Movsumov
Farid Movsumov

Reputation: 12725

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

return $next($request);

Upvotes: 0

Kevin
Kevin

Reputation: 825

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

Upvotes: 1

syyu
syyu

Reputation: 407

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

Upvotes: -3

CG_DEV
CG_DEV

Reputation: 818

Try this, in the public/index.php page

error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set("display_errors", 1);

Upvotes: 35

Related Questions