Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have tried PHP's ftp_site($ftpStream, 'chgrp nobody '.$directory) but I cannot get it to work. Does anyone out there have any success changing a directories group via ftp_connect() in PHP? Thanks.

share|improve this question
Shouldn't that be on stackoverflow ? – Dominik Mar 10 '10 at 17:59
Are you able to manually issue a chgrp command while connected to the ftp server via a CLI client? Does the user you are connect as have permissions to do this? Does the ftp server even support chgrp? – Zoredache Mar 10 '10 at 18:01
@Dominik, not necessarily. The issue could be related to the configuration or type of ftp server. – Zoredache Mar 10 '10 at 18:04
Yes I can issue the chgrp command via telnet session. Here is what appears in my error log file: PHP Warning: ftp_site() [<a href='function.ftp-site'>function.ftp-site</a>]: SITE chgrp is an unknown extension in /usr/www/php/chgrp.php on line 22 – H. Ferrence Mar 10 '10 at 18:23
P.S. I can ultimately achieve what I need by chmod-ing the directory to 0777 but I do not want to do that. For security purposes, I want to change the group on the dir to nobody while not opening up the directory to the world. – H. Ferrence Mar 10 '10 at 18:27

This is not actually a php issue, but an ftp server issue. You stated in a comment, the php error log contained:

Warning: ftp_site() [function.ftp-site]: SITE chgrp is an unknown extension in /usr/www/php/chgrp.php on line 22

This simply means that the ftp server does not support the CHGRP command. If you try a desktop ftp application, or ftp from the command line, you should receive the same error back from the ftp server when trying to change the group.

Since you have access to the server, why not just chgrp the directory from the command line?

chgrp <path> <groupname>

share|improve this answer
..."why not just chgrp the directory from the command line" because the app I am writing is dynamic and runs from the browser. I do not want the app to be impeded by me manually needing to (a) get some sort of notification that I need to CHGRP and (b) then manually telnet in to do it. Thanks for the response though. – H. Ferrence Mar 12 '10 at 12:51

Let me ask this...

If I use a Deny from all directive on this directory, yet set its permissions to 0757 (drwxr-xrwx) is that too dangerous?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.