I have a Symfony project in production and after running sudo php app/console cache:clear --env=prod
, the folder's permissions become
drwxr-xr-x 11 root root 4096 Feb 29 15:08 prod
This doesn't allow the user www-data
(apache default user) to access it anymore.
How can I clear the cache and have www-data read/write to the cache folder?
Also, running php console cache:clear
for the dev mode I get
The stream or file "../app/logs/dev.log" could not
and dev.log file has been created with following permissions:
be opened: failed to open stream: Permission denied-rw-r--r-- 1 www-data www-data 2840530 Feb 29 15:01 dev.log
See "Setting up Permissions" in http://symfony.com/doc/current/book/installation.html#configuration-and-setup.
If you use Ubuntu you can use setfacl
sudo setfacl -R -m u:www-data:rwX -m u:`whoami`:rwX app/cache app/logs
sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
EDIT:
$ rm -rf var/cache/* var/logs/* var/sessions/*
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
$ sudo chmod -R +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" var
$ sudo chmod -R +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" var
If there is no command setfacl on your pc you need install it;
sudo apt-get install acl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With