Permissions and ownership of /var/www [duplicate]

I am using Ubuntu 13.04 VPS and have installed LAMP (apache2). Now I have uploaded my web files (WordPress) in /var/www. But I dont have permissions to write in files.

When I run WordPress install, it says that it could not write on wp-config php file. So I execute this command over SSH

su
cd /var/www
sudo chown www-data:www-data -R *
/etc/init.d/apache2 restart

(www-data is my apache user).Still itv cant write into files. I also cannot upload files using FTP (transfer failed error).

The permissions for directories in /var/www are 755 and for files are 644. Setting permissions 777 resolves the problem but I dont want to CHMOD it 777.

Please help me out.. Thx.


Try with:

sudo chown -R [USER NAME]:[USER NAME] /var/www

Replace [USER NAME] with appropriate.