I'm trying to set up a basic LAMP stack on Ubuntu Server so that I can host a dozen or so WordPress websites, all within /var/www. The only problem is WordPress can't write the wp-config file! I don't know if this is due to incorrect user permissions involving my user or www-data or something or if it's due to the whole 777 / 775 / 665 permissions thing.
What I've found is that by default my user cannot write to /var/www, but if I run chown the problem is fixed. Remember, at this point there are no files within /var/www.
sudo chown user:www-data /var/www
Tacking on -R doesn't help because, again, there are no files in there yet. So once I run this, thus giving my user ownership of /var/www, I can copy over the WordPress directory over sFTP. But now when I go to run the WordPress install it tells me that it cannot write the wp-config file.
What am I doing wrong or what am I missing? Am I running chown correctly, or should I be doing something different like www-data:www-data or user:apache or something?