Setting up a website in home directory instead of /var/www

I have an Apache web server set up with cakephp as the framework on Ubuntu. But I got bugged very quickly at having to sudo to edit every file since they were placed in /var/www. Besides, it didn’t strike me as the right thing to do.

So, a quick google on “/var/www on ubuntu” took me to this page which turned out to be exactly what I was looking for. You can set it up so that http://localhost points to a folder in your home directory (/home/user/public_html). Now I can edit all files without sudo and it works with http://localhost.