[英]laravel centOS 7 chmod 755/775 permission denied"could not be opened: failed to open stream: Permission denied", only allows if I set to 777
I have linux:我有Linux:
Linux version 3.10.0-693.21.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Wed Mar 7 19:03:37 UTC 2018
Linux 版本 3.10.0-693.21.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Wed Mar 7 19:03:37 UTC 2018
If I set the permission to 777 on storage, laravel works, but if I set it to 755 or 775 it says:如果我将存储权限设置为 777,laravel 可以工作,但如果我将其设置为 755 或 775,它会说:
"The stream or file "/home/admin/domains/linkshift.eu/public_html/storage/logs/laravel-2018-11-08.log" could not be opened: failed to open stream: Permission denied"
“无法打开流或文件“/home/admin/domains/linkshift.eu/public_html/storage/logs/laravel-2018-11-08.log”:无法打开流:权限被拒绝”
I have tried searching for an answer, but nothing else worked, I have tried doing Permissions Issue with Laravel on CentOS but it still doesn't work我试过寻找答案,但没有其他工作,我试过在 CentOS 上使用 Laravel进行权限问题,但它仍然不起作用
Edit: I also have direct admin installed编辑:我也安装了直接管理员
Look like the log file is generated using root user and you are running the laravel from a different user.看起来日志文件是使用 root 用户生成的,并且您正在从不同的用户运行 laravel。 Make sure the log file is written by same user.
确保日志文件是由同一用户写入的。 Or give permission to your user.
或授予您的用户权限。
sudo chown -R laravel-user:laravel-user /path/to/your/laravel/root/directory
Run these commands after every deploy每次部署后运行这些命令
chmod -R 775 storage/framework
chmod -R 775 storage/logs
chmod -R 775 bootstrap/cache
Still If not working, It can maybe also because of SELinux.如果不工作,也可能是因为 SELinux。
Check selinux status on terminal:在终端上检查 selinux 状态:
sestatus
If status is enabled, write command for disable SElinux (not recommended)如果状态为启用,则编写禁用 SElinux 的命令(不推荐)
setenforce Permissive
or you can do like below.或者你可以像下面这样做。
yum install policycoreutils-python -y # might not be necessary, try the below first
semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/your/laravel/root/directory/storage(/.*)?" # add a new httpd read write content to sellinux for the specific folder, -m for modify
semanage fcontext -a -t httpd_sys_rw_content_t "/path/to/your/laravel/root/directory/bootstrap/cache(/.*)?" # same as the above for b/cache
restorecon -Rv /var/www/html/ # this command is very important to, it's like a restart to apply the new rules
Selinux is intended to restrict access even to root users, so only the necessary stuff might be accessed, at least on a generalist overview, it's extra security, disabling it is not a good practise, there are many links to learn Selinux, but for this case it is not even required. Selinux 旨在限制甚至 root 用户的访问,因此只能访问必要的内容,至少在通才概述中,这是额外的安全性,禁用它不是一个好习惯,有很多链接可以学习 Selinux,但为此如果它甚至不需要。
Could you show the result of你能展示一下结果吗
ls -l /home/admin/domains/linkshift.eu/public_html/storage/logs
and have you tried你有没有试过
php artisan config:cache
php artisan config:clear
composer dump-autoload -o
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.