PHP fopen() fails on files even with wide-open permissions

前端 未结 3 1452
醉话见心
醉话见心 2021-01-02 09:29

I\'m currently migrating my LAMP from my Windows Server to a VPS running Debian 6. Most everything is working, however, one of the PHP scripts was failing to write to its c

相关标签:
3条回答
  • 2021-01-02 10:22

    Remember that in order to reach a file, ALL parent directories must be readable by www-data. You strace output seems to indicate that even accessing /var/log/apache2/writetest is failing. Make sure that www-data has permissions on the following directories:

    • / (r-x)
    • /var (r-x)
    • /var/log (r-x)
    • /var/log/apache2 (r-x)
    • /var/log/apache2/writetest (rwx)
    • /var/log/apache2/writetest/writetest.log (rw-)
    0 讨论(0)
  • 2021-01-02 10:24

    Could be a SELinux issue, even if Debian doesn't ship it in the default installation your provider could have enabled it. Look for messages in /var/log with

    grep -i selinux /var/log/{syslog,messages}
    

    If that's the cause and you need to disable it, here are instructions: look for file /etc/selinux/config, here it's default content. Change SELINUX directive to disabled and reboot the system.

    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #   enforcing - SELinux security policy is enforced.
    #   permissive - SELinux prints warnings instead of enforcing.
    #   disabled - SELinux is fully disabled.
    SELINUX=disabled
    # SELINUXTYPE= type of policy in use. Possible values are:
    #   targeted - Only targeted network daemons are protected.
    #   strict - Full SELinux protection.
    SELINUXTYPE=targeted
    
    0 讨论(0)
  • 2021-01-02 10:29

    Does the php file doing the writing have proper permissions set? Try changing those to see if that's the issue.

    0 讨论(0)
提交回复
热议问题