regarding chown

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skway
Forum Newbie
Posts: 5
Joined: Wed Sep 22, 2010 1:23 pm

regarding chown

Post by skway »

Dear All,

I am having problem changing owner of file . what I am doing is uploading file and after that changing its owner
by writing chown command , I am not able to change the owner at all .

can any body let me know how to do that ... by default it is giving owner as apache
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: regarding chown

Post by cpetercarter »

On Unix/Linux systems, only the root user can change the owner of a file, as the php manual explains.
skway
Forum Newbie
Posts: 5
Joined: Wed Sep 22, 2010 1:23 pm

Re: regarding chown

Post by skway »

cpetercarter wrote:On Unix/Linux systems, only the root user can change the owner of a file, as the php manual explains.

is there any other option to tackle this situation, I have seen ftp commands but there is no command for changing the ownership
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: regarding chown

Post by requinix »

Work around it. Probably will end up chmod 0777-ing instead.

Why do you need to change the ownership? Are you on shared hosting? What files are you dealing with?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: regarding chown

Post by pickle »

There should be no reason to change the ownership, unless

a) you've got users logging into the shell that need to modify them or
b) you've got a cron job running on the server as a different user.

In both of those cases, you may put the Apache user in a group with the other users, then set the sticky group writable bit on the directory. All future created files will then be writable by group members.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
skway
Forum Newbie
Posts: 5
Joined: Wed Sep 22, 2010 1:23 pm

Re: regarding chown

Post by skway »

@tasairis
I am working on dedicated server..


@pickle &
the thing is whenever I upload any file I am getting apache as user,
and ftp user which is not able to overwrite these files when I do all change all files user as ftp user I am able to overwrite files, the ftp user has access to all folders on server...
this the problem I am facing
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: regarding chown

Post by pickle »

Forget what I said about the sticky bit - apparently I was misunderstanding what it did.

You can do what ~tasairis suggestd & change the permissions on the file to world writable.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
skway
Forum Newbie
Posts: 5
Joined: Wed Sep 22, 2010 1:23 pm

Re: regarding chown

Post by skway »

@pickle

here is the summary what I have done
1-->uploaded file
2-->changed permission as 777 with php chmod function
3--> tried to set owner with php chown function

no success on 3rd point not able to change owner , i must change the owner :!:
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: regarding chown

Post by pickle »

Well you're screwed then. Only the root user can change ownership.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
skway
Forum Newbie
Posts: 5
Joined: Wed Sep 22, 2010 1:23 pm

Re: regarding chown

Post by skway »

ohhhhhhhhh allright .... will check it out ....
Post Reply