If you are going to be the user maintaining the site, then make it so that your userid can edit the files.
cd /var/www && sudo chown -R `whoami`:`whoami` .
If you do this, then you will be able to modify the files under /var/www because the files will belong to you and your personal group. The -R runs the command recursively - it runs on the current file (the directory) and all the files in and under the directory (included the hidden files)
If you have not run a sudo command recently (a few minutes), it will ask you for your personal password.
It is also possible to set up groups and all that. However, this is the simplest way.
Make sure that the files are readable by the web server. If this is a problem, then - because you own the files now you can use chmod command:
cd /var/www && chmod -R o+r .
If this does not make the directories executable, you may want to also do:
find /var/www -type d -print0 | xargs -0 chmod o+x
This will (find) collect the list of directory names and pass them on (as a null delimited list) to xargs, which will execute the chmod to make the directories executable.
As reported at related: Whats the simplest way to edit and add files to "/var/www"?, – Desmond Hume Nov 12 '12 at 14:42 suggested to
For security reasons, it's probably better keep /var/www owned by root:root, so instead of
sudo chgrp -R www-data /var/www it better be
sudo chgrp -R www-data /var/www/*