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

Rikki

Member
Mar 10, 2003
20
0
151
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
 

Rikki

Member
Mar 10, 2003
20
0
151
Hey there, thanks I will try this.

User 99 and Group 99 it seems.

FTP seems to be 32003:32005

Thanks

Rik
 

domhandy

Member
Nov 3, 2008
7
0
51
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
 
Last edited: