Default File Permissions Apache /var/www/
www-data is a user/group set created specifically for web servers. It should be listed in /etc/passwd as a user, and can be configured to run as another user in /etc/apache2/apache2.conf.
Basically, it’s just a user with stripped permissions so if someone managed to find a security hole in one of your web applications they wouldn’t be able to do much. Without a lower-user like www-data set, apache2 would run as root, which would be a Bad Thing® since it would be able to do anything and everything to your system.
Make sure the group is www-data on ‘/var/www’.
sudo chgrp www-data /var/www
Make ‘/var/www’ writable for the group.
sudo chmod 775 /var/www
Set the GID for www-data for all sub-folders.
sudo chmod g+s /var/www
Your directory should look like this on an ‘ls -l’ output.
Last, add your user name to the www-data group (secondary group).
sudo useradd -G www-data [USERNAME]
sudo chown [USERNAME] /var/www/
You should now be able to SFTP to your server as your user name and upload to ‘/var/www’ with no problems.