简体   繁体   中英

Laravel 5.6 Uncaught RuntimeException: A facade root has not been set. in vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218

After installing Laravel 5.6 on PHP 7.1.8 (fedora 23) using composer, when I try to open url in browser, I get this error

PHP Fatal error:  Uncaught RuntimeException: A facade root has not been set. in vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218\nStack trace:  
\n#0 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(396): Illuminate\\Support\\Facades\\Facade::__callStatic('replaceNamespac...', Array)  
\n#1 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(373): Illuminate\\Foundation\\Exceptions\\Handler->registerErrorViewPaths()  
\n#2 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(288): Illuminate\\Foundation\\Exceptions\\Handler->renderHttpException(Object(Symfony\\Component\\HttpKernel\\Exception\\HttpException))  
\n#3 vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(187): Illuminate\\Foundation\\Exceptions\\Handler->prepareResponse(Object(Illuminate\\Http\\Request), Object(Symfony\\Co in vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 218

I have installed Laravel using composer and there were no error while installation. All directories have enough permissions (I've just granted write permission to apache for directories specified by official Laravel installation guide.)

What should I do to fix this error?

After trying a lot, I realized this was an issue due to SELinux in force in my system. SELinux prevented apache from writing to required files.

$ /usr/sbin/getenforce
Enforcing

I disabled SELinux to confirm this doubt and it worked properly once SELinux was disabled. So I just needed to set proper permission for my project, so SELinux can allow apache to write to necessary files.

$sudo chcon -t httpd_sys_rw_content_t /path/to/my/laravel/project/dir -R

I hope this will help to those who are facing same issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM