Portal Home > Knowledgebase > Articles Database > PHP copy() is coping files as user nobody??


PHP copy() is coping files as user nobody??




Posted by insanelymacintosh, 08-02-2008, 02:37 PM
Hey guys, I am currently creating a PHP script that will copy a file from one location to another copy ($sourceFile, $destFile); The problem is the owner of the sourcefile and the destFile are different? The owner of the sourcefile is myUsername:myUsername, but after doing the copy the owner of the destFile changes to nobody:nobody? Does anyone know how to keep the same owner of the file? I am currently using CPanel and have suPHP enabled, so the PHP script should be running as the user "myUsername" and not nobody. Any help would be very grateful! Thanks!

Posted by greg2007, 08-03-2008, 08:07 AM
Someone 'might' correct me on this, but I would imagine that APACHE/PHP will always take ownership unless you use specific server settings and code to change that. I imagine it's possible to do that, but is it worthwhile? I'm guessing a bit as you didn't provide a lot of info as to what you are doing, but the 'usual way' would be to create a reference in a db table for the file uploaded and a refernce in the same row to the user who owns it.... id -> username -> file_ref

Posted by ub3r, 08-03-2008, 08:21 AM
check your phpinfo to see how you are running php. If it's running as an apache module, you're doing it wrong.

Posted by CodyRo, 08-03-2008, 11:28 AM
SuPHP to the rescue!

Posted by bager, 08-04-2008, 03:56 PM
you can use the chown function, but this depends on your apache and php configuration

Posted by qbert220, 08-04-2008, 04:14 PM
SuPHP is not working. Login to WHM as root, click "Configure PHP and SUExec" to check your server configuration.

Posted by larwilliams, 08-04-2008, 04:49 PM
SuPHP is definitely not running if the file is being set as being owned by the "nobody". Look at "Configure PHP and SuEXEC" in WHM and make sure your default PHP version is set to use "suphp". If you follow my advice, it will work properly.

Posted by iFuseDan, 08-06-2008, 12:57 PM
That is of course, providing that the Apache / PHP build done through WHM featured suPHP in the module lineup; if not then you'd have to recompile the pair, you can use either suPHP or FCGI (with SuExec), both will end up runing php under user, instead of "nobody".



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read