我收到 error_log 文件的消息“无法打开流或文件“.../laravel.log”:无法打开流:权限被拒绝”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44668311/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I got message for error_log file "The stream or file ".../laravel.log" could not be opened: failed to open stream: Permission denied"
提问by Sangwondee
Tue Jun 20 13:17:41.195156 2017] [:error] [pid 14454] [client 203.131.216.144:60475]
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)\n#1
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#2
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)\n#3
/var/www/html/app/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)\n#4
/var/www/html/app/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('er in
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107, referer: http://203.131.209.179/app/login
2017 年 6 月 20 日星期二 13:17:41.195156] [:error] [pid 14454] [client 203.131.216.144:60475]
PHP 致命错误:未捕获的异常“UnexpectedValueException”,消息为“无法打开流或文件“/var/www/html/app/storage/logs/laravel.log”:无法打开流:权限被拒绝”
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\n堆栈跟踪:\n#0
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)\n#1
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#2
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array) \n#3
/var/www/html/app/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array) \n#4
/var/www/html/app/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('er in
/var/www/html/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php 107行,参考:http: //203.131.209.179/app/login
回答by Alexey Mezenin
Directory Permissions
After installing Laravel, you may need to configure some permissions. Directories within the
storage
and thebootstrap/cache
directories should be writable by your web server or Laravel will not run.
目录权限
安装 Laravel 后,您可能需要配置一些权限。内的目录
storage
和bootstrap/cache
目录应该是可写的Web服务器或Laravel将无法运行。
https://laravel.com/docs/5.4/installation#installing-laravel
https://laravel.com/docs/5.4/installation#installing-laravel
So, for example, in Linux you can do this by executing chmod
command:
因此,例如,在 Linux 中,您可以通过执行以下chmod
命令来执行此操作:
chmod -R 755 storage bootstrap/cache
回答by Motiur Rahaman
In your project directory run this command:
在您的项目目录中运行以下命令:
chmod -R 777 storage bootstrap/cache
chmod -R 777 storage bootstrap/cache