在CentOS 7.1.1503(Core)中,Php错误:failed to open stream: Permiss


Php Error : failed to open stream: Permission denied in CentOS 7.1.1503(Core)

我正在运行Apache/2.4.6 (CentOS) build Aug 24 2015 18:11:25 on CentOS Linux release 7.1.1503 (Core) 64位。我在"w"模式和"a"模式下打开文件时也面临一个问题。我找了很多。尝试了所有提到的步骤,但我仍然没有得到想要的结果。同样的文件可以让我在Windows 10中以"w"模式和"a"模式打开。但它在CentOS中不起作用。目录'/var/www/html/editable'中有一个名为'home.php'的文件。当我尝试从文件srvr_file_access.php以'w'模式或'a'模式打开该文件时,我得到以下错误:

PHP警告:fopen(/var/www/html/editable/home.php): failed to open/var/www/html/srvr_file_access.php

我已将该文件和目录的所有者和组更改为'apache',并已分配权限755home.php文件和目录的权限如下:

home。

-rwxr-xr-x+ 1 apache apache 0 Oct 11 14:41 home.php

/var/www/html/可编辑

drwxr-xr-x+ 2 apache apache   21 Oct 11 14:56 editable

有谁能帮我解决这个问题吗?

谢谢。

对于仍然有这个问题的人,我通过在/var中创建文件夹来解决它,然后使用chown apache:apache folder_name,然后移动到www文件夹

cd [laravelfolder]

chmod 777 storage -Rsudo chcon -t httpd_sys_rw_content_t storage

chmod 777 bootstrapsudo chcon -t httpd_sys_rw_content_t bootstrap -R