You should look in the directory where your script is.
Use ls -la to show all files in the folder and their permissions (to execute php script file must have at least x bit assigned to www-data or its group).
Also all the parent directories up to / MUST have x bit assigned to user/group for apache to be able to change directory to.
Look. You have Tree structured Files system:
/var/www is in /var
/var/www/esm is in /var/www
/var/www/esm/symfony is in /var/www/esm
So www-data user should have the ability to Execute (x bit) all of that directories.
So when in / execute ls -l and look wheter /var has x bit for www-data user or it's group (drwxrwx---) and it owns this directory. When in /var execute ls -l an so on...
You can change permissions to 777 for every directory. But DO NOT use -R key. Just change permissions to the directory only.