使用 lampp 托管时如何修复 "Slim Application Error" 错误
How to fix "Slim Application Error" error while using lampp to host
我在 linux 机器上使用 lampp 来托管网站。数据库被配置为虚拟主机。此外,php 依赖项是使用 composer 修复的。当我启动 lampp 组件并转到 locahost 时,我收到了这个错误。我试图以某种方式修复它,但没有任何效果。
希望您能帮帮我,谢谢。
Slim 应用程序错误
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}
从你的错误输出来看,它显示了一些权限问题,你可以将根文件夹的所有访问权限授予 sudo chmod 777
并确保您在 api 正文中提供有效数据并将有效 json 数据传递给响应
好的,抱歉打扰了,我只是解决了使用 chmod -R a+wr logs/
修复日志文件夹的写入和读取权限的问题。
谢谢。
我在 linux 机器上使用 lampp 来托管网站。数据库被配置为虚拟主机。此外,php 依赖项是使用 composer 修复的。当我启动 lampp 组件并转到 locahost 时,我收到了这个错误。我试图以某种方式修复它,但没有任何效果。 希望您能帮帮我,谢谢。
Slim 应用程序错误
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}
从你的错误输出来看,它显示了一些权限问题,你可以将根文件夹的所有访问权限授予 sudo chmod 777
并确保您在 api 正文中提供有效数据并将有效 json 数据传递给响应
好的,抱歉打扰了,我只是解决了使用 chmod -R a+wr logs/
修复日志文件夹的写入和读取权限的问题。
谢谢。