Symfony can’t write in cache folder on CentOS 7 even with the right permissions

  centos, nginx, permissions, php, symfony

Symfony cannot write in cache folder even i give full permissions to that folder

chmod 777 -R /path/to/symfony/var

But I am always getting these error

Cache directory "/path/to/symfony/var/cache/dev" is not writable.

I am on Centos 7 and I use nginx and php7

I never had this problem on Ubuntu or Windows. It’s just when i moved my application to CentOS

One suggest to me to run those commands on the var folder

chcon -R -t httpd_sys_content_rw_t /path/to/symfony/var
systemctl restart nginx

This solution worked once. But after a while i got the same problem.
I tried to re-run tose commands but nothing changed.

Any ideas?

Source: Symfony Questions