0

I have a user named 'user' which I use to login to the ftp of my website.

However, this presents me with a problem.

If I want to allow my user to access to ftp, I have to typ the following:

chown -R user:ftpusers /var/www/

By doing this, my website is no longer available when surfing to it. To make it available again, I have to typ the following command:

chown -R www-data:www-data /var/www/

the user 'user' is in both the ftpusers and www-data group. How can I fix this so I wouldn't have to typ this anymore?

I'm using apache2 and vsftpd on ubuntu

3
  • chown www-data:ftpusers, perhaps? Jan 3, 2012 at 12:46
  • By doing that, the website works, but the ftp fails
    – SnIpY
    Jan 3, 2012 at 12:51
  • SnIpY: You may need chmod g+w to add group write permissions. Jan 3, 2012 at 12:58

1 Answer 1

1

To best share with multiple users who should be able to write in /var/www, it should be assigned a common group. For example the default group for web content on Ubuntu and Debian is www-data. Make sure all the users who need write access to /var/www are in this group.

sudo usermod -a -G www-data <some_user>

Then set the correct permissions on /var/www.

sudo chgrp -R www-data /var/www
sudo chmod -R g+w /var/www

Additionally, you should make the directory and all directories below it "set GID", so that all new files and directories created under /var/www are owned by the www-data group.

sudo find /var/www -type d -exec chmod 2775 {} \;    

Find all files in /var/www and add read and write permission for owner and group:

sudo find /var/www -type f -exec chmod ug+rw {} \;

You must log in to answer this question.

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