1

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?

Ashutosh Sharma
  • 434
  • 1
  • 9
  • 20
FMoridhara
  • 161
  • 5
  • 16
  • Did you modify any code from the default laravel instalation whatsoever? is is this 100% fresh? – Quezler May 14 '18 at 09:34
  • @Quezler ys its 100% fresh. I haven't touched any code. I just installed, configured the host and checked the url. – FMoridhara May 14 '18 at 09:53
  • When you run any `php artisan` command on that instalation, do you get the same error? – Quezler May 14 '18 at 11:44
  • I get artisan help info when I run php artisan from the root folder of my application. I dont see any error, may be I need to check that differently but I have no clue. – FMoridhara May 14 '18 at 12:02
  • (i know you know, just mentioning for others:) possibly related: https://stackoverflow.com/questions/49818102/laravel-5-6-uncaught-runtimeexception-a-facade-root-has-not-been-set – Quezler May 14 '18 at 12:07
  • have you setup the .env properly ? – punk73 May 15 '18 at 00:57
  • @Quezler When I run `php artisan serve` from root folder and checked `http://127.0.0.1:8000/` in browser, I can see application home page. – FMoridhara May 15 '18 at 06:26
  • @punk73 ys I made changes for APP_URL and kept all other settings with default values. But that does not work. I can see some configurations which I have not made any change or not sure if that should be kept or removed. F.e MIX_PUSHER_APP_KEY and MIX_PUSHER_APP_CLUSTER – FMoridhara May 15 '18 at 06:32

1 Answers1

-1

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.

FMoridhara
  • 161
  • 5
  • 16
  • You do not want to make your entire project directory writable. Only the `storage` and `bootstrap/cache` directories need to be writable by the web server process. And that would not have caused the error you were seeing. – miken32 Jun 08 '18 at 16:00
  • Ys, its not needed for whole project – FMoridhara Jun 11 '18 at 11:48