本文介绍了PHP无法用mkdir目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个previously工作的PHP脚本,它能够创建一个目录的mkdir

  $ webfolder =在/ var / www / html等/图片/用户;
的mkdir($ webfolder,0770);

我做了一些修改该文件夹的/ var / www / html等/图像这是现在的权限设置:

  drwxrwx ---。自己的Apache system_u:object_r:httpd_sys_content_t:S0图片

我觉得previously这个文件夹是由拥有阿帕奇。但是,由于阿帕奇已阅读的完全权限,写和执行作为用户组,我不知道为什么它不能创建中的文件夹。使用的mkdir 生成一个布尔值。

该问题是由于目录的所有权还是有其他原因?请注意,我使用的PHP版本5.4。

错误日志说:

解决方案

The answer is staring right in front of me, but I miss it due to my unfamiliarity with SELinux.

The SELinux context type should be set as httpd_sys_content_rw_t instead of httpd_sys_content_t so that the folder is both readable and writable for apache. Changing the context recursively is done with the following command:

# chcon -R -t httpd_sys_content_rw_t /var/www/html/images

Good grief. Hope it helps others who come across this.

这篇关于PHP无法用mkdir目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 05:53
查看更多