Super User is a question and answer site for computer enthusiasts and power users. 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 a VM running Ubuntu 10.10. I'm using Netbeans and uploading files to an ftp on the virtual machine. I'm using vsftpd.

The problem I'm having is, the owner of the folder /var/www is the user apache in order for the apache server to be able to read the files. So far so good.

But when I try to upload a file from ftp user user1 I'm not able to. I know what the problem is. My question is, how do I set up permissions correctly for the user apache and user1 to be able to write/read all the files in /var/www directory?

share|improve this question
up vote 13 down vote accepted

Create a group www-users and make it the group owner of /var/www. Then assign the users apache and user1 to the group and set the permissons on the /var/www directory to 775. This will allow user1 and any other users in the www-users group to read and write to /var/www; it will also make it easier to authorize other users to write to /var/www — simply assign the user to the www-users group.

Edit: The correct permissions on /var/www is 2775, which includes setgid so that files and directories inside /var/www inherit the group ownership of /var/www.

share|improve this answer
Great answer. Except apache isn't able to read the files after I upload something with user1 I ran the following commands: chown -R apache:www-users /var/www, usermod -g www-users apache, usermod -g www-users user1, chmod 775 /var/www. Am I missing something? – Tek Apr 7 '11 at 17:22
The umask may be set to deny read permissions from others; see if changing the umask helps. – bwDraco Apr 7 '11 at 21:51
Yep. That was part of it. – Tek Apr 7 '11 at 22:06
Here are the steps in case any googlers need a hint. 1) set up vsftpd for umask 0027 (/etc/vsftpd.conf) [local_umask=0027] 2) create www-users group (groupadd www-users) 3) add user to group (usermod -a -G group user) 4) Set apache to run as www-users group (httpd.conf) 5) chgrp www-users /var/www 6) chmod 2775 /var/www – Tek Apr 7 '11 at 22:09
Also, try adding setgid permission to the directory: chmod g+s /var/www. This will ensure that files and directories created inside the directory are owned by the group that owns the directory. – bwDraco Apr 7 '11 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .