位于第84行的 /var/www/vhosts/mapper.pavementlayers.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php 文件中。
位于第84行的 /var/www/vhosts/mapper.pavementlayers.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php 文件中。
可能是SElinux阻止了Apache创建此文件。
为了测试这一点,您可以使用以下命令暂时禁用SElinux:
setenforce 0
这将把SElinux置于宽容模式。这意味着您仍会在SElinux日志文件中收到错误消息,但SElinux不会阻止命令。
要重新激活SElinux,您可以输入:
setenforce 1
或重新启动您的CentOS服务器。
不幸的是,我也在CentOS上使用Laravel 5时遇到了问题,原因是SElinux。 最终我禁用了SElinux。我知道这不是正确的做法,但我还没有时间让它们一起工作!
所以我最终有时间进一步调查了这个问题,并且我让SELinux与Laravel 5一起正常工作了。我刚刚更新了这篇文章,为可能遇到此问题的人提供帮助。禁用SELinux不是最佳策略,如上所述。
需要完成三件事:
The folders Storage and Bootstrap/Cache need to have the right SELinux context. This can be achieved via the following commands:
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/<Laravel Site>/storage(/.*)?"
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/<Laravel Site>/bootstrap/cache(/.*)?"
The SELinux context needs to be applied on the directories:
restorecon -Rv "/var/www/<Laravel Site>/storage"
restorecon -Rv "/var/www/<Laravel Site>/bootstrap/cache"
The Apache user needs to have the rights to create files in both directories. This can be achieved via a ACL in CentOS 7:
setfacl -R -m u:apache:rwX storage/
setfacl -R -m u:apache:rwX bootstrap/cache/
最后一件要做的事情是重新启用SELinux。
尝试使用这些命令来操作Laravel 5
$ php artisan cache:clear
$ sudo chmod -R 777 app/storage
$ composer.phar dump-autoload
这是因为对于我的情况,Laravel没有权限写入日志文件。
$ sudo chmod -R 755 storage/
$ sudo chown -R www-data storage/
$ sudo chgrp -R www-data storage/
$ php artisan cache:clear
$ php artisan config:cache
$ composer dumpautoload
不是所有步骤都是必要的。
你必须确保 storage
文件夹存在。如果你是从 git 部署的,确保 storage
文件夹本身被跟踪并自动创建。
关于Laravel 5.7
$ cd /var/www/html/ $ php artisan cache:clear 应用程序缓存已清除!
适用于CentOS 7
# ausearch -c 'httpd' --raw | audit2allow -M my-httpd
# semodule -i my-httpd.pp
由于 laravel.log 文件位于 storage 文件夹中,因此我建议您在 Mac 终端上运行此命令。
chmod -Rf 0777 storage