How to avoid using sudo when working in /var/www?
Permissions mystify me. I'm worried about compromising the security of my folder, too, since it's public.
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
To give only your user permission to /var/www. You want to change the group owner to your primary group. If your username is joe this is how you would do it.
You then need to chmod the directory so its writable by the group joe.
after that you can write to /var/www
If you want to be able to edit and delete existing files. You need to take ownership of them.