Welcome to WebmasterWorld Guest from 54.145.44.134

Forum Moderators: bakedjake

Message Too Old, No Replies

Owner nobody 99 99 after files are manipulated through PHP

     

rowtc2

2:19 pm on Oct 24, 2013 (gmt 0)

5+ Year Member



I didn't found on Google how to solve this issue, maybe someone may help me.


I have a dedicated server where i host a few sites. On all of them i face this problem.

When i copy image files from one folder to another or when i resize images via PHP script, the new images has owner nobody (99 99) and i cannot overwrite them when i run again the script.

When i upload images via FTP the owner for images is correct.
Owner/Group 526 522


After i resize or copy images in another folder via PHP script i have this owner:
Owner/Group 99 99


I have read the problem is that PHP and FTP are not in the same group.


What i need to do to have Owner/Group 526 522 after image resize or copy?

lammert

3:49 pm on Oct 24, 2013 (gmt 0)

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



You can change the owner of the new file in PHP with the chown() function. More information can be found in the PHP documentation [php.net].

graeme_p

6:05 am on Oct 25, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month



Yes, it is usual for PHP (or Apache if you are using mod_php) to run as "nobody" to limit its access to the file system to reduce the damage that can be done if the server is hacked.

You can configure PHP/Apache to run as a different user, but if you run it as a user that has write access to your .php files or anything important, you are giving up a layer of security. If you run PHP as fastcgi rather than mod_php, it can be a different user from Apache.

I do not think chown() is going to work because it requires PHP to be running as root, which is a really bad idea.

The right solution is probably to configure things so that it is OK for files written by PHP to belong to "nobody".
 

Featured Threads

Hot Threads This Week

Hot Threads This Month