homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

fopen/fwrite and owner/group settings
How to change the owner/group?

 8:55 am on Jan 5, 2006 (gmt 0)

Hello there,

I Have a problem with some file writeing.

I Use fopen to create a new file, but that file gets the owner and group the same as the apache owner and group.

How can i change it so that the file gets the same owner/group as the files i upload with FTP?

If you think this post belongs to apache then please move this post :).

Thx in advanced,



 2:26 pm on Jan 5, 2006 (gmt 0)

Why would you want to change the owner/group to the FTP user? Why not keep it as the user that uploaded the file?


 10:16 pm on Jan 5, 2006 (gmt 0)


That is what i mend :p

I think i just fraised it wrong..

I Want the owner of the file to be the owner when it gets executed.

And that isn't the way it is now.


 10:24 pm on Jan 5, 2006 (gmt 0)

exec("chown newowner /path/to/the/file.jpg");


 12:18 am on Jan 6, 2006 (gmt 0)

If you do not run your own server
check with your ISP

Quite a few ISPs won't allow you to change ownership


 9:28 am on Jan 6, 2006 (gmt 0)

chown doesn't work...
Only root can change owners (atleast on our server).
But owners can change groups.


The only solution i can find is to use suExec or something like that.
But that means i have to use CGI, and then the perferonase goes down.

Is there an other solution for this problem?

Thx in advanced.


 4:16 pm on Jan 6, 2006 (gmt 0)

But owners can change groups.

Then how about chgrp [php.net]?


 5:36 pm on Jan 6, 2006 (gmt 0)

chgrp is fine, if you want to let the group have write access.
But on a server with multiple hosts this just isn't secure.

i Mabye have found a create tool that works just like suExec for CGI scripts.

Thisone is called suPHP [suphp.org], this together with Safe_Mode should do the trick of what i want :).

It will start the script using the owner/group of the script, and therefor every file created by that script will be of the same owner/group.

I haven't tryed it yet, but i have seen some good posts about it.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved