If the files are reverting back to 644 after you change them to 777, this is most likely an Apache issue and is typically caused by the owner:group being set incorrectly.
This can also be caused by servers running cpanel and the automatic script running to fix insecure file permissions.
If the server is running php as a fastcgi, this could also cause a issue when the file owner:group is set incorrectly.
Make sure you main home directory, typically /home/username is actually owned:group'd to your username for your account.
|