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

Hey, I run a server powered Ubuntu 10.04 LTS. the software stack that I use comprises of

  • PHP fpm-fcgi Version 5.3.6
  • Web Server: nginx/0.8.54

To make, things like wordpress work properly. I have done chown www-data:www-data on my public_html folder. This was all files are easily modifiable by nginx and things like Auto Updating wordpress work as expected.

The problem arises when I login via ftp and try to upload new files or change existing ones. Since, I use username as Gaurish & all files are owned www-data my requests are denied.

Response:   220 (vsFTPd 2.2.2)
Command:    USER gaurish
Response:   331 Please specify the password.
Command:    PASS ************
Response:   230 Login successful.
Command:    OPTS UTF8 ON
Response:   200 Always in UTF8 mode.
Status: Connected
Status: Starting upload of /tmp/cachegrind.out.5513
Command:    CWD /home/gaurish
Response:   250 Directory successfully changed.
Command:    PWD
Response:   257 "/home/gaurish"
Command:    TYPE I
Response:   200 Switching to Binary mode.
Command:    PORT 192,168,1,6,214,6
Response:   200 PORT command successful. Consider using PASV.
Command:    STOR cachegrind.out.5513
Response:   553 Could not create file.
Error:  Critical error
Status: Disconnected from server

I need a way by which I(gaurish) & nginx(www-data) can both modify the files. Any idea how to do that?

share|improve this question
up vote 1 down vote accepted

Shared group is one way as others have previously answered.

A more complex alternative would be to use a source revision control system like CVS, Subversion, GIT, etc.. Then a single admin cgi page,running as the webserver, can update all modified files on the server. This also ensures that you have a backup of the previous file before you overwrite it, given that source control is enforced.

Whatever you do, learn and use SSH and SCP not FTP. FTP should be used for the convenience of your users if absolutely needed, not for system administration.

share|improve this answer
Any idea how can I run nginx can user, instead of www-data? – CuriousMind Jun 4 '11 at 10:44

You need to do a few things to get a complete solution:

  • Add your user to the www-data group (as per @fbh's answer).
  • Configure the FTP server umask to 007 so that files are uploaded with group write privileges.
  • Set the setgid flag (g+s) on your directories such that new files are group-owned by the directory's group, rather than the file creator's primary group.
share|improve this answer

Add your user to the webservers group

usermod -a -G www-data gaurish
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.