As many PHP servers as are out there you would think that there would more guides on this topic.
Joe begins as the happy owner of a new ubuntu PC.
Joe likes Ubuntu in his coffee. Joe wants to build a website using PHP. Joe apt-get's hundreds and hundreds of libraries trying to setup Apache, PHP, and MySQL. Joe finally gets PHP setup as the sunrise knocks poor tired Joe out.
Joe wakes up with PHP working. Joe starts writing code. Joe gets errors that PHP can't create files.
This bothers Joe.
Joe naively CHMOD's the /var/www directory to 0777. PHP works and Joe is happy. Several minutes later Joe has the same problem when PHP tries to write another file.
Joe realizes this is bad.
Joe discovers chown and a group known as www-data. Joe reverses his CHMOD and chowns the /var/www to www-data. However, PHP still won't work. PHP is nobody.
Joe goes back to work for McDonalds realizing there is no hope of ever writing PHP code.