Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t使文件/dir可由php写入_Php_Linux_File Permissions_Silverstripe - Fatal编程技术网

Can';t使文件/dir可由php写入

Can';t使文件/dir可由php写入,php,linux,file-permissions,silverstripe,Php,Linux,File Permissions,Silverstripe,我在CentOS 7机器上使用PHP编写文件和目录时遇到问题 我已经在网上和网站上搜索过了,但还没有找到适合我的解决方案(我对linux相当陌生) 到目前为止,我已经尝试了以下内容,关于为什么文件/dirs仍然不能由PHP编写,有什么想法吗 sudo chown -R apache:apache ss/ sudo chmod -R g+rw ss/ sudo chmod -R 777 ss/ 在找到带有echo getmyuid()的id后,还尝试了以下命令。:'.getmygid() 我已

我在CentOS 7机器上使用PHP编写文件和目录时遇到问题

我已经在网上和网站上搜索过了,但还没有找到适合我的解决方案(我对linux相当陌生)

到目前为止,我已经尝试了以下内容,关于为什么文件/dirs仍然不能由PHP编写,有什么想法吗

sudo chown -R apache:apache ss/
sudo chmod -R g+rw ss/

sudo chmod -R 777 ss/
在找到带有echo getmyuid()的id后,还尝试了以下命令。:'.getmygid()

我已经运行了以下命令

# egrep -i '^user|^group' /etc/httpd/conf/httpd.conf
User apache
Group apache

ls -Zd ss/
drwxrwxrwx. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 ss/

这似乎是一个selinux限制,请尝试使用:
chcon-R-t httpd\u sys\u rw\u content\u ss/


关于,

您使用的PHP代码是什么?您确定正在访问正确的目录/文件吗?另外,对于dir“ss”,ls-la的输出是什么?显示您所需要的;ve triedYou在使用上述命令时确实没有返回任何错误?http服务器以什么帐户执行?那个帐户和组真的被称为“apache”吗?这不是很常见。。。然后:您试图使用的文件夹
ss
在哪里?使用绝对寻址可能不会那么混乱。一般情况下:通常不需要
0777
的文件权限,这是一个非常坏的习惯。你不应该用那个。它在您的系统中引入了一个巨大的安全漏洞。此文件夹的安全上下文是什么?请使用
ls-Zd ss/
检查,我在另一个答案上使用了下面命令中的帐户和组apache#egrp-I'^user | ^group'/etc/httpd/conf/httpd.conf user apache group apache ss文件夹位置是/var/www/html/ss安全上下文命令返回了drwxrwx。apache未限定\u:object\r:httpd\u系统\u内容\u t:s0 ss/
# egrep -i '^user|^group' /etc/httpd/conf/httpd.conf
User apache
Group apache

ls -Zd ss/
drwxrwxrwx. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 ss/