Add your user to www-data
group.
sudo adduser USERNAME www-data
Then, change recursively the ownership of /var/www
to your username.
sudo chown USERNAME:www-data -R /var/www
At last, change permissions to 755 and add g+s to directories to ensure all new files created have the same group as the directory's.
sudo chmod 0755 -R /var/www
sudo chmod g+s -R /var/www