[英]php fopen failed to open stream: Permission denied
我在使用php寫入文本文件時遇到問題。 這可能聽起來很簡單,但我已將文件所有者和組設置為apache / root,777的權限,我仍然無法寫入文件。 我用php 5.3.8運行centos。
====================
New info
====================
semanage fcontext -l | grep httpd | grep rw
/var/lib/drupal(/.*)? all files system_u:object_r:httpd_sys_script_rw_t:s0
/var/spool/gosa(/.*)? all files system_u:object_r:httpd_sys_script_rw_t:s0
/var/lib/bugzilla(/.*)? all files system_u:object_r:httpd_bugzilla_script_rw_t:s0
/var/spool/viewvc(/.*)? all files system_u:object_r:httpd_sys_script_rw_t:s0
為了允許目錄為r / w,我使用chcon
命令將httpd_sys_script_rw_t
類型添加到目錄及其下的任何內容:
chcon -R -t httpd_sys_script_rw_t <directory>
-R
標志使命令遞歸。
-t
標志將文件的擴展屬性設置為指定的文件上下文。 在這種情況下,httpd文件上下文httpd_sys_script_rw_t
在以下情況下使用:
您希望httpd_sys_script_exec_t腳本讀取/寫入數據,並禁止其他非sys腳本訪問。
httpd_selinux(8)
手冊頁中描述了用於允許HTTPd寫入磁盤的適當文件上下文(以及其他操作的布爾值httpd_selinux(8)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.