Summary of steps:
- Add current logged in user to www-data group
- Change ownership of /var/www directory to www-data group
- Change permissions of /var/www to 775 so that all members of www-data can have access to full access of /var/www. Note that this is not 755. If we set 755 then group members cannot have full access. That is why we are using 775.
Step 1: Assuming that 'ubuntu' is name of user with wich you are access ftp through filezilla then you can add that user to www-data group So log into server via SSH and then run following command
sudo usermod -aG www-data ubuntu
Let's say if you are already logged in as user 'ubuntu' to SSH then to add current logged in user to www-data group, you have to run following command.
sudo usermod -aG www-data $USER
Step 2: Change the ownership of the /var/www directory to www-data group.
sudo chown -R www-data:www-data /var/www
Step 3: Sets the proper permissions so you can upload files via sftp, manage files via command-line, and upload plugins and media directly. With following command, all members of www-data group will have full access to files and folders in /var/www
sudo chmod -R 775 /var/www
If you want to undertsand more about 775 permissions then check this guide here http://permissions-calculator.org/decode/775/ Note that 775 will give access to all members of group www-data. But 755 allows only owner to have full access.
Step 4: Set the proper permissions for files so that www-data group members and owners can edit / delete files.
sudo chmod -R 664 /var/www
Note that 664 will give access to all members of group www-data. But 644 allows only owner to have full access.
Step 5: You can apply changes to all files and folders using following command:
sudo find /var/www/ -type d -exec chmod 775 {} \;
sudo find /var/www/ -type f -exec chmod 664 {} \;