I have a few Symfony2 sites that I'm having problems regarding the cli user, and the cache directory.
CentOS 6.7 Apache 2.2.31 PHP 5.5.28 Symfony 2.7.1 (using Symfony3 dir structure)
I have followed the instructions on the Symfony2 installation guide, and I'm using the setfacl method to correctly set the permissions on the cache folder. As seen here (part 3):
http://symfony.com/doc/current/book/installation.html
On our server the http user is 'nobody'. I have added this to the portion of the script that determines the http user, that is ran before the actual change of permissions.
HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx|[n]obody' | grep -v root | head -1 | cut -d\ -f1`
Where things go wrong is when I'm logged in via ssh and I run the scripts to clear production cache:
php bin/console cache:clear --env=prod
What is happening if I run this command is that the cache folder is deleted, then it is 'warmed up' so the folder is recreated, but now I am the owner (not nobody), and the permissions on the directory are no longer set the same.
//Before (immediately after setting S2 permissions):
drwxrwsr-x+ 2 nobody (group) 4096 Aug 27 08:00 cache/
//After running command and cache is warmed up:
drwxr-sr-x 6 (my SSH user) (group) 4096 Aug 27 08:03 cache/
...or i run this...
php bin/console cache:clear --env=prod --no-warmup
If I run this command without the warmup, the cache folder is still deleted, but as soon as it gets some traffic, the cache folder is recreated, this time owned by nobody, but again the permissions are incorrect.
//Before (immediately after setting S2 permissions):
drwxrwsr-x+ 2 nobody (group) 4096 Aug 27 08:07 cache/
//After running command and cache is rebuilt:
drwxr-sr-x 6 nobody (group) 4096 Aug 27 08:10 cache/
This continuously causes problems for 'nobody' regarding not being able to create directories inside the cache folder. The only way I've found around it is to reset permissions on those folders after every single time the cache directory is recreated after clearing the cache.
It seems to me that the clear:cache commands should be deleting the contents of the cache directory, not the directory itself. Otherwise you have to reset the permissions every time you clear the cache. This just does not seem right to me.
Any help would be appreciated.