The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Script uploads and MkDir - owner/group problem means FTP cant access files

Discussion in 'General Discussion' started by Rikki, Sep 7, 2011.

  1. Rikki

    Rikki Member

    Joined:
    Mar 10, 2003
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Hi there, was tricky trying to condense my question for the subject title :)

    Basically I have a script that takes a ZIP file from a user, decompresses it on the server, creates a new directory, puts the decompressed files there and then generates thumbnails.

    All is well and it works great, but if there is an error, a file is wrong or something like that I cant manually go in via FTP and yank that file out to replace it, delete it or overwrite it.

    Seems any disk work done by PHP is under the guise of a certain user and going in after the fact with FTP or even cPanel's file manager doesnt work as Im not allowed to touch anything.

    Is there anyway to sort this so when my scripts are creating things, folders or files, that I can go in later and ammend?

    Many thanks for your help,

    Rik
     
  2. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,449
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    SuPHP is most likely the best answer.

    nobody?
     
  3. Rikki

    Rikki Member

    Joined:
    Mar 10, 2003
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Hey there, thanks I will try this.

    User 99 and Group 99 it seems.

    FTP seems to be 32003:32005

    Thanks

    Rik
     
  4. domhandy

    domhandy Member

    Joined:
    Nov 3, 2008
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    United Kingdom
    cPanel Access Level:
    Root Administrator
    Assuming you are running the Apache PHP handler as DSO, you need to make the owner of the directory the siteuser and put the group as nobody (which is 99), which is what Apache is running under.

    chgrp -R nobody /home/username/public_html/directory
    chown -R username /home/username/public_html/directory

    That should fix all the files and folders in the directory so they are accessible via Apache (for writing to the directory) and also via the site owner via FTP.

    Have the permissions on the folder as 775 so Apache (nobody) can still write to it as it won't be the owner now.

    chmod 775 /home/username/public_html/directory

    I have a lot of my CMS sites set-up like this to avoid the insecure 777 setting on folders.

    Anyone using suPHP as the PHP handler wouldn't have this problem.

    Cheers

    Dom
     
    #4 domhandy, Sep 7, 2011
    Last edited: Sep 7, 2011
Loading...

Share This Page