上传文件时权限被拒绝

时间:2015-05-01 10:37:40

标签: php amazon-web-services file-permissions centos7

当我上传文件时显示

"未能打开流:权限被拒绝"

我已经 777 对文件目标目录 / tmp 目录的权限 777 权限即使我已经将apache用户分配给/ tmp和目的地目录我不知道实际问题在哪里,我正在运行亚马逊Aws centos 7架构与PHP 5.4 我有gd图书馆和所有基本需要扩展上传图像...

1 个答案:

答案 0 :(得分:2)

很可能您的服务器启用了selinux。 Security Enhanced Linux为攻击提供了增强的强化功能,但需要更多的管理工作。

如果您的文件/目录属性后跟一个点,则可以使用扩展的selinux属性:

[root@www tmp]# ls -ld
drwxrwxrwt. 14 root root 4096 May  4 08:45 .
          ^-- this dot means: there are more selinux attributes

要显示扩展属性,您可以使用-Z参数:

[root@www tmp]# ls -Zd
drwxrwxrwt. root root system_u:object_r:tmp_t:s0       .

当然你可以禁用selinux,但我不推荐它。要允许Web服务器写入目录,您可以使用chcon命令:

chcon -R -t httpd_sys_content_rw_t /path/to/directory