简体   繁体   English

laravel centOS 7 chmod 755/775 权限被拒绝“无法打开:无法打开流:权限被拒绝”,仅当我设置为 777 时才允许

[英]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.

相关问题 777我的整个应用程序出现“无法打开流:权限被拒绝” - “failed to open stream: Permission denied” after 777 my entire app laravel - 无法以追加模式打开流或文件“/storage/logs/laravel.log”:无法打开流:权限被拒绝 - laravel - The stream or file “/storage/logs/laravel.log” could not be opened in append mode: failed to open stream: Permission denied 未能打开流:Laravel中的权限被拒绝 - failed to open stream: Permission denied in Laravel Laravel 5:无法打开流:权限被拒绝 - Laravel 5: Failed to open stream: Permission denied 在 append 模式下无法打开 stream 或文件“/var/www/alphacomodate/storage/logs/laravel.log”:无法打开 ZF7B44CFAFD5C52223D5498196C7A8: - The stream or file “/var/www/alphacomodate/storage/logs/laravel.log” could not be opened in append mode: failed to open stream: Permission denied 权限被拒绝,但文件是chmod 777 - Permission denied, though files are chmod 777 file_put_contents() 无法打开 stream:权限在 CentOS 上被拒绝 - file_put_contents() failed to open stream: Permission denied on CentOS Php 错误:无法打开 stream:CentOS 7.1.1503(核心)中的权限被拒绝 - Php Error : failed to open stream: Permission denied in CentOS 7.1.1503(Core) Laravel的权限被拒绝Centos 7 - Laravel permission denied Centos 7 Laravel 5.6“无法打开流:filesystem.php 中的权限被拒绝” - Laravel 5.6 "failed to open stream: Permission denied in filesystem.php"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM