Resolving a problem in the cache and logs folder in Symfony 2.0

I tried several ways to grant permission to the cache and logs , but whenever I clear the cache at that time, the problem arises as the inability to write to the directory.

I tried two ways:

  • Full cache access via root with 777 permissions.
  • Change the owner as www-data , as said in the Symfony2 docs.

but it did not work for me.

+6
source share
6 answers

Decision:

Do not disable SELinux if you care about security, if the site is accessing the global network at all. In this case, you will want to “Use” SELinux and not disable it, this is not for some reason.

I'm doing it;

 # 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 that your httpd , apache or wwwdata web server user is added to your user group, regardless of the group your user is in. Thus, when apache writes to the symfony directory that you recompiled with assetic when the cache was launched, for example, the part of g ugo , which is your user group, will allow the apache user to allow the user to contain these products.

And by the way, I mean, how lame is the decision to disable SELinux, without any disclaimer?

+4
source

If you do not want to disable SElinux, here is the 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 
+7
source

Why is this happening

The most common situation when such a problem occurs is when your web server user does not have the right to write to the folder to which the project belongs. In fact, changing the owner of the application / cache and applications / logs does not always help, because you can run some tests or console commands that run from your user (php-cli / php-fpm). As a result, the folder with the cache or logs will be created by your current user, and the user of the web server will not have access to it.

Decision

My suggestion is either to add a web server user (which is probably www-data) to your user group or start a web server from your user - and you will forget about such a problem forever;)

Similar issue, well-explained answer: Symfony2 permissions

+3
source

See the "Configuring Permissions" section in the "Configuring and Configuring" section. I recommend using the setfacl approach.

+2
source

Permanently disable SElinux

To permanently disable SElinux, you need to edit the SElinux configuration file / etc / selinux / config and add / change a line to disable it: SELINUX = disabled

-1
source

Disable SELinux security using the following command as the su user.

 echo 0 > /selinux/enforce 
-3
source

Source: https://habr.com/ru/post/920672/


All Articles