The Apache web server runs as user www-data. It needs to have access to your web files.
However, it does not necessarily need to have
write access. See
this Linode guide for more information on managing permissions.
You will find it impossible to completely clean up your existing system. You need to start with a new install. The problem is whatever service that was compromised, probably one of your web services. With your new install, make sure you are using web services that have the latest security patches. Otherwise it will just be compromised again.