Laravel blank white screen

匿名 (未验证) 提交于 2019-12-03 01:12:01

问题:

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

Heres my virtual host directive:

DocumentRoot "/var/sites/laravel/public" ServerName laravel.mydomain.com      AllowOverride All     allow from all     Options +Indexes     Require all granted

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

回答1:

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

# 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


回答2:

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

$ sudo chmod -R o+w storage/


回答3:

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



回答4:

Try this, in the public/index.php page

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


回答5:

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


回答6:

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.



回答7:

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


回答8:

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



回答9:

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

return View::make('yourview');

as opposed to

View::make('yourview');



回答10:

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



回答11:

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



回答12:

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

return $next($request);


回答13:

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



回答14:

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



回答15:

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;



回答16:

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.



回答17:

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



回答18:

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

sudo service apache2 restart


回答19:

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


转载请标明出处:Laravel blank white screen
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!