Default File Permissions Apache /var/www/

Apache2 Permissions

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’.

Code:
sudo chgrp www-data /var/www

Make ‘/var/www’ writable for the group.

Code:
sudo chmod 775 /var/www

Set the GID for www-data for all sub-folders.

Code:
sudo chmod g+s /var/www

Your directory should look like this on an ‘ls -l’ output.
drwxrwsr-x

Last, add your user name to the www-data group (secondary group).

Code:
sudo useradd -G www-data [USERNAME]
Code:
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.

extradrmtech

Since 30 years I work on Database Architecture and data migration protocols. I am also a consultant in Web content management solutions and medias protecting solutions. I am experienced web-developer with over 10 years developing PHP/MySQL, C#, VB.Net applications ranging from simple web sites to extensive web-based business applications. Besides my work, I like to work freelance only on some wordpress projects because it is relaxing and delightful CMS for me. When not working, I like to dance salsa and swing and to have fun with my little family.

You may also like...