2

I'm using lampp on my linux machine to host a website. The db is configured as the virtual host. Also, the php dependencies are fixed using composer. When I start the lampp components and I go to locahost I recive this error. I tried to fix it in some ways, but nothing worked. Hope you can help me, thank you.

Slim Application Error

The application could not run because of the following error:

Details

Type: UnexpectedValueException
Message: The stream or file "../logs/app.log" could not be opened: failed to open stream: Permission denied
File: /opt/lampp/htdocs/starlight-app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
Line: 107

Trace

#0 /opt/lampp/htdocs/starlight-app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(39): Monolog\Handler\StreamHandler->write(Array)
#1 /opt/lampp/htdocs/starlight-app/vendor/monolog/monolog/src/Monolog/Logger.php(344): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /opt/lampp/htdocs/starlight-app/vendor/monolog/monolog/src/Monolog/Logger.php(637): Monolog\Logger->addRecord(200, 'Loading route.', Array)
#3 /opt/lampp/htdocs/starlight-app/config/middlewares.php(94): Monolog\Logger->info('Loading route.', Array)
#4 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#5 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Closure), Array)
#6 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#7 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#8 /opt/lampp/htdocs/starlight-app/vendor/slim/csrf/src/Guard.php(171): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#9 [internal function]: Slim\Csrf\Guard->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#10 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Slim\Csrf\Guard), Array)
#11 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#12 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#13 /opt/lampp/htdocs/starlight-app/config/middlewares.php(178): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#14 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#15 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array(Object(Closure), Array)
#16 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))
#17 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), O Object(Slim\Http\Response), Object(Closure))
#18 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))
#19 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/App.php(405): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#20 /opt/lampp/htdocs/starlight-app/vendor/slim/slim/Slim/App.php(313): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#21 /opt/lampp/htdocs/starlight-app/public/index.php(70): Slim\App->run()
#22 {main}
aSemy
  • 5,485
  • 2
  • 25
  • 51
Triad
  • 152
  • 1
  • 4
  • 12
  • _The db is configured as the virtual host_ What does that mean. A Virtual Host is an Apache concept and nothing to do with the DBMS – RiggsFolly Jun 10 '19 at 11:24

2 Answers2

2

Ok sorry for bothering you, I simply resolved the problem fixing the permissions o writing and reading on the logs folder using chmod -R a+wr logs/. Thank you.

Triad
  • 152
  • 1
  • 4
  • 12
1

As of your error output it is showing some permissions issue you can give all access to the root folder as sudo chmod 777

And make sure you are providing the valid data in api body and passing the valid json data to the response

Ajay Kumar
  • 99
  • 6
  • Probably it could fix the problem, but changing permissions on all the root folder caused me a lot of problems in a past project. Thank you anyway. – Triad Jun 10 '19 at 11:33