I am setting up a new server and installed Ubuntu 18.04 in combination with Apache2. My project is stored in /var/www/project
. In apache2.conf I added
<Directory /var/www/project/>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
In my virtualhosts file I point to /var/www/project/public
When I go to the Ip address of my server I see my project and everything works, except one thing:
whenever I clear the cache with php bin/console cache:clear
the permissions of my directory var
are messed up which results in errors in the production environment.
I can fix this with:
chmod -R 777 var/
But the problem returns wheneven I clear the cache again. I tried with different users including root
, but always the same problem. I do not understand what is causing this. In the documentation on file permissions it says:
In Symfony
3.x
, you needed to do some extra work to make sure that your cache directory was writable. But that is no longer true! In Symfony4
, everything works automatically
Well not for me, but what could cause the problem?
The cache directory is owned by the user executing the cache:clear
command.
www-data
.www-data
can't write in cache directoryexecute cache:clear using the user owning the files.
su www-data -s /bin/bash
./bin/console cache:clear
Depending on your settings, your
www-data
user may be different