Php Apache没有对html文件夹的写入权限

Php Apache没有对html文件夹的写入权限,php,apache,chmod,Php,Apache,Chmod,我在CentOS 7中安装了apache,MySQL,PHP。除了apache不能在html文件夹中写入文件之外,所有这些都可以正常工作。我在使用文件内容时发现了这个问题。我试过了 将/var/www的所有者更改为apache:apache,不起作用 在httpd.conf中添加了Order allow,denyallow至,重新启动httpd服务,不工作 chmod-R 0777/var/www/html,不工作 我的服务器有什么问题?请帮帮我 更新1:ls-al/var/www/html的结

我在CentOS 7中安装了
apache
MySQL
PHP
。除了apache不能在html文件夹中写入文件之外,所有这些都可以正常工作。我在使用
文件内容时发现了这个问题。我试过了

  • /var/www
    所有者更改为
    apache:apache
    ,不起作用
  • httpd.conf
    中添加了
    Order allow,deny
    allow至
    ,重新启动
    httpd
    服务,不工作
  • chmod-R 0777/var/www/html
    ,不工作
  • 我的服务器有什么问题?请帮帮我

    更新1:ls-al/var/www/html的结果

    total 40
    drwxrwxrwx.  5 apache apache 4096 Sep 23 10:19 .
    drwxr-x---.  4 apache apache   31 Sep 18 01:50 ..
    drwxrwxrwx. 15 apache apache 4096 Sep 23 08:43 folder1
    drwxrwxrwx+ 10 apache apache 4096 Sep 23 10:19 folder2
    -rwxrwxrwx.  1 apache apache 1574 Sep  5 08:55 favicon.ico
    -rwxrwxrwx.  1 apache apache  603 Sep 22 05:05 .htaccess
    -rwxrwxrwx.  1 apache apache 9841 Sep  8 08:34 index.php
    drwxrwxrwx.  8 apache apache 4096 Sep 23 08:44 folder3
    
    更新2:apache
    error\u log
    (我更改了所有IP地址)-已编辑,更改为新的error\u log,在停止
    httpd
    后,备份error\u log,启动
    httpd

    [Thu Sep 24 07:06:47.540295 2015] [core:notice] [pid 14439] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
    [Thu Sep 24 07:06:47.541787 2015] [suexec:notice] [pid 14439] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    [Thu Sep 24 07:06:47.569389 2015] [so:warn] [pid 14439] AH01574: module rewrite_module is already loaded, skipping
    [Thu Sep 24 07:06:47.572287 2015] [auth_digest:notice] [pid 14439] AH01757: generating secret for digest authentication ...
    [Thu Sep 24 07:06:47.573315 2015] [lbmethod_heartbeat:notice] [pid 14439] AH02282: No slotmem from mod_heartmonitor
    [Thu Sep 24 07:06:47.600913 2015] [mpm_prefork:notice] [pid 14439] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
    [Thu Sep 24 07:06:47.600943 2015] [core:notice] [pid 14439] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
    

    a.txt文件的权限问题


    警告:文件内容(a.txt):无法打开流:第2行/var/www/html/index.php中的权限被拒绝

    谢谢大家!我修复了此指南的问题:


    我希望这会有帮助。

    如果您想要有效的答案,请提供
    ls-l/var/www/html
    、代码和错误消息。在
    chmod 0777
    之后。15 apache 4096年9月23日08:43 folder1
    drwxrwx+10 apache 4096年9月23日10:19 folder2
    -rwxrwx。1 apache 1574 Sep 5 08:55 favicon.ico
    -rwxrwx。1 apache 9841 Sep 8 08:34 index.php
    drwxrwx。8 apache 4096 Sep 23 08:44 folder3
    @blueqn您可以发布此代码的输出吗
    @blueqn另外,您可以在调用
    put\u file\u contents()
    的地方发布PHP行吗?谢谢..我选中了,
    SELinux状态:enabled
    只需在/var/www/html路径上键入以下命令,并提供结果ls-lZThank供您回复。这是结果
    drwxrwx。apache-apache-unconfined\u:object\r:httpd\u-sys\u-content\u-t:s0 folder1
    drwxrwx+apache-apache-unconfined\u-object\r:httpd\u-sys\u-content\u-t:s0 folder2
    -rwxrwx。ApacheApacheUnconfined\u:object\r:httpd\u sys\u content\u t:s0 favicon.ico
    -rwxrwx。ApacheApacheUnconfined\u:object\r:httpd\u sys\u content\u t:s0 index.php。apache未定义\u:object\r:httpd\u sys\u content\u t:s0 folder3
    您在哪里找到了a.txt文件?它有权限吗?