我在Linux机器上使用lampp托管一个网站。该数据库被配置为虚拟主机。此外,php依赖关系是使用composer修复的。当我启动lampp组件并转到locahost时,我会看到此错误。我试图以某种方式修复它,但是没有任何效果。 希望您能帮助我,谢谢。
Slim Application Error
由于以下错误,该应用程序无法运行: 细节 类型:UnexpectedValueException 消息:流或文件“ ../logs/app.log”无法打开:流打开失败:权限被拒绝 文件:/opt/lampp/htdocs/starlight-app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php 线:107 跟踪
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)< / p>
3 /opt/lampp/htdocs/starlight-app/config/middlewares.php(94):Monolog \ Logger-> info(“加载路线”,数组)
4 [内部功能]: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 [内部功能]: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),对象(关闭)
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 [内部功能]: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 [内部功能]: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),对象(关闭)
13 /opt/lampp/htdocs/starlight-app/config/middlewares.php(178):Slim\App->Slim{closure}(Object(Slim\Http\Request)、Object(Slim\Http\Response ))
14 [内部功能]: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 [内部功能]: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 对象(Slim \ Http \ Response),对象(关闭)
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}
答案 0 :(得分:1)
从错误输出开始,它显示了一些权限问题,您可以将所有对根文件夹的访问权限授予sudo chmod 777
并确保您在api主体中提供了有效数据并将有效json数据传递给响应
答案 1 :(得分:0)
抱歉,打扰您了,我只是解决了解决权限问题,即使用chmod -R a+wr logs/
写入和读取日志文件夹。
谢谢。