Templates_c permissions differ when rebuilt on command line or by apache
civibuild shows a few ways to tackle this problem.

File Permission ACL's work well if they are available on your system.

Edit: You will need to set the ACLs to cover future files created in the directory as well as existing ones. For this, use the -d flag as shown here https://serverfault.com/a/445096.

Further edit: Set the ACLs on the civicrm directory above the templates_c directory. Sometimes the whole templates_c directory gets deleted and rebuilt.