I have tried some ways to give permission to the cache
& logs
folder but whenever I clear cache at that time the problem occurs like unable to write in directory.
I have tried this two ways:
root
user with 777
permissions.www-data
as said in Symfony2 docs. but it didn't work for me.
Don't disable SELinux if you care about security if the site is global facing in anyway. In this case you would want to "Use" SELinux, not disable it, it's there for a reason.
I do this;
# chcon -R -t httpd_sys_script_rw_t /var/www/symfonyapp/app/cache
# chcon -R -t httpd_sys_script_rw_t /var/www/symfonyapp/app/logs
# apachectl restart #(or systemctl restart httpd) or (service restart httpd) to restart your server, a reboot will suffice as well.
And yes, @Viataley has one good point, now you need to check to make sure your web server user httpd
, apache
, or wwwdata
is added to your users group, whatever group your user is in. This way when apache writes to the symfony directories that you user has recompiled through assetic when you run a cache clear for e.g., the g
portion of the ugo
which is your users group, will allow apache
user permission to those dirs contents.
If you do not want to turn off SElinux, here is a solution :
cd your/symfo/app
chcon -R -t public_content_rw_t app/cache
chcon -R -t public_content_rw_t app/logs
setsebool -P allow_httpd_anon_write 1
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