Re: Cannot connect to localhost after permission change
The default permissions are correct - only root should be able to write to /var/www and you should copy your files to that folder as root instead of loosening it's permissions.
By default, /var/www is readable by all, but your changes stopped that. Now that you have partly rectified that by making www-data the owner, you could try restarting Apache (rebooting will do this, or use 'sudo service apache2 restart').
You could also try adding read permission to /var/www for all, which is a default permission anyway:
sudo chmod a+r /var/www
I try to treat the cause, not the symptom. I avoid the terminal in instructions, unless it's easier or necessary. My instructions will work within the Ubuntu system, instead of breaking or subverting it. Those are the three guarantees to the helpee.