I have changed my DocumentRoot to ~/www.
The permissions of it are 0774.
I have added the www-data user to my user's group and the owner of ~/www is my own user and group (user:user).
The problem is that apache can't write to this directory. It can write only if I set www-data as owner, but if I do that, I can't write at the directory. The opposite thing applies too.
This is more like a Linux question, not Ubuntu but I really hope that you can help me. Thanks!