'Failed to open stream: Permission denied' 错误 - Laravel 5.1
'Failed to open stream: Permission denied' error - Laravel 5.1
我的 Ubuntu 14.04 和 Laravel 5.1 应用程序出现问题。
当我的应用程序想要记录时我遇到了这个错误:
Uncaught UnexpectedValueException: The stream or file storage/logs/l could not be opened: failed to open stream: Permission denied in /var/www/releases/20160426/booking_server/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87\nStack trace:\n#0........it continues
我找到了这个解决方案:
sudo php artisan cache:clear
sudo chmod -R 777 storage
sudo composer dump-autoload
但问题是这只是暂时的。问题每天都出现,我总是不得不这样做。
我可以做些什么来阻止这种情况每天发生?
PD:我有每日日志,但如果可能的话我想保持这种方式。
看起来他们以前在这里处理过 similar issue。您有任何 artisan 手动 运行 或通过 cron 运行 的命令吗?如果是这样,解决这个问题,这样他们 运行 作为您的网络用户可能会有所帮助。
如果没有,我真的认为在这组中最容易适用的解决方案是 this one:
sudo setfacl -R -m u:www-data:7 /full/path/to/storage
如果命令不起作用,我找到了一个可能的替代形式:
setfacl -d -m g:www-data:rw /full/path/to/laravel/storage/logs
setfacl
并没有像它应该的那样流行,它确实是为网络服务器设置权限的最佳方法之一。
不建议将服务器上的目录设为全局可写 (chmod 777)。
像这样设置权限,(假设网络服务器在 www-data 组下 运行ning)
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
参考这个:https://laracasts.com/discuss/channels/general-discussion/laravel-framework-file-permission-security
关于您的问题:
似乎有一个进程 运行ning 每天使用 root 权限创建日志文件。您确定没有相同的 cron 设置吗?
如果没有,请在 storage/logs 目录中 运行 ls -l
并将输出粘贴到此处。 (在手动更改权限之前执行此操作)
我的 Ubuntu 14.04 和 Laravel 5.1 应用程序出现问题。
当我的应用程序想要记录时我遇到了这个错误:
Uncaught UnexpectedValueException: The stream or file storage/logs/l could not be opened: failed to open stream: Permission denied in /var/www/releases/20160426/booking_server/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87\nStack trace:\n#0........it continues
我找到了这个解决方案:
sudo php artisan cache:clear
sudo chmod -R 777 storage
sudo composer dump-autoload
但问题是这只是暂时的。问题每天都出现,我总是不得不这样做。
我可以做些什么来阻止这种情况每天发生?
PD:我有每日日志,但如果可能的话我想保持这种方式。
看起来他们以前在这里处理过 similar issue。您有任何 artisan 手动 运行 或通过 cron 运行 的命令吗?如果是这样,解决这个问题,这样他们 运行 作为您的网络用户可能会有所帮助。
如果没有,我真的认为在这组中最容易适用的解决方案是 this one:
sudo setfacl -R -m u:www-data:7 /full/path/to/storage
如果命令不起作用,我找到了一个可能的替代形式:
setfacl -d -m g:www-data:rw /full/path/to/laravel/storage/logs
setfacl
并没有像它应该的那样流行,它确实是为网络服务器设置权限的最佳方法之一。
不建议将服务器上的目录设为全局可写 (chmod 777)。 像这样设置权限,(假设网络服务器在 www-data 组下 运行ning)
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
参考这个:https://laracasts.com/discuss/channels/general-discussion/laravel-framework-file-permission-security
关于您的问题: 似乎有一个进程 运行ning 每天使用 root 权限创建日志文件。您确定没有相同的 cron 设置吗?
如果没有,请在 storage/logs 目录中 运行 ls -l
并将输出粘贴到此处。 (在手动更改权限之前执行此操作)