write permissions to directories other than /var/www and /tmp

Discussion in 'Apache' started by Tim-Erwin, Nov 10, 2008.

  1. #1
    Hi guys,

    sorry for crossposting. Posted my issue in the php section because it was related to sth I found there. However, actually it's an apache topic. (Might be the reason that I didn't get an answer for days...)

    In short, my problem is that apache (on Fedora 9) says it was not permitted to write to other directories than /var/www/html/ and /tmp/.

    fopen("/opt/www-data/test.log", "a");

    gives Permission Denied. I checked the permissions on the filesystem, apache is the owner (if not, still everybody has write permission). The path is correct.

    getmyui() and getmygid() give 48 and 48. stat('/opt/www-data/test.log')['uid'|'gid'] same values. I tried using /tmp instead, works. I cannot see why I can't write to /opt.

    Also tried using system("touch /opt/www-data/test") which gives the same issue. On the console with sudo -u apache touch /opt/www-data/test it works.

    Any idea? (As always: works on another system but can't see the difference.)

    Thanks,
    Tim
     
    Tim-Erwin, Nov 10, 2008 IP
  2. hoodvs

    hoodvs Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's probably the open_basedir value, check which paths are available in either your apache config or php config.
     
    hoodvs, Nov 10, 2008 IP
  3. vovaNux

    vovaNux Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Does this issue relate just to /opt directory? Are you able to create files in any other directories?
     
    vovaNux, Nov 12, 2008 IP
  4. Tim-Erwin

    Tim-Erwin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey,

    thanks for the reply. Have not been at work the last days, so I didn't answer before, sorry. I checked the open_basedir option; it is not set.

    It's not only related to /opt but to all directories other than /tmp and /var/www/html

    Tim
     
    Tim-Erwin, Nov 17, 2008 IP
  5. Tim-Erwin

    Tim-Erwin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Any more ideas? Maybe related to vhosts or document roots? I still have no idea. I can "sudo -u apache touch /opt/www-data/log" but apache itself refuses to do so.
     
    Tim-Erwin, Nov 18, 2008 IP
  6. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #6
    does this output the user you expect ?

    echo `whoami`;
    Code (markup):
    It's possible that PHP isn't executing using Apaches' credentials if something like suPHP is being used.
     
    joebert, Nov 18, 2008 IP
  7. Tim-Erwin

    Tim-Erwin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yes, it does. Gives "apache". Checked that as well with getmyuid() and stat(), which give matching results.
     
    Tim-Erwin, Nov 18, 2008 IP