Even late to the party, recently I had problems about
Out of Memory just accessing app.php file with Symfony 3.4. Turns out that when you have SELinux set to
enforcing, even if you set the permissions of
var directory inside your project to 777, it won't be able to write on it. If you follow the steps in the official documentation about how deploy in production, it will return a response code 500 and write in web server's error log only that PHP has exhausted the memory limit.
I'm no expert in SELinux, but the only way I could solve this problem was disabling SELinux, but edition
/etc/selinux/config file setting
SELINUX=disabled and restarting the OS.
Again, there's reason to SELinux exists and proper configuration isn't found easily using Symfony's
var sub-folders and can get hard to solve this problem without thinking of disabling SELinux.