Answer the question
In order to leave comments, you need to log in
Bug in Symfony. Why does Vich uploader crash on production after clearing the cache?
Installed VichUploader in Symfony 4.3. And everything is fine, but in prod after use php bin / console cache: clear
, a problem arises:
Uncaught PHP Exception InvalidArgumentException: "The directory "/var/www/test.site/var/cache/prod/vich_uploader" is not writable." at /var/www/test.site/vendor/jms/metadata/src/Cache/FileCache.php line 44 {"exception":"[object] (InvalidArgumentException(code: 0): The directory \"/var/www/test.site/var/cache/prod/vich_uploader\" is not writable. at /var/www/test.site/vendor/jms/metadata/src/Cache/FileCache.php:44)"}
Answer the question
In order to leave comments, you need to log in
There are at least 2 reasons.
1) The user under which apache/nginx runs and the user who runs the console script are often different. This means that files and folders created after clearing the cache (and clearing the cache not only deletes, but also creates new files) will conflict in rights, either the user or apache / nginx will have access to them, but not both.
2) Apache by default creates folders with 755 permissions and files with 644 permissions, which means that if you add a user to the apache group, you won't be able to access them. Here you also need to configure the umask correctly.
Your postscript is the answer to the question.
The cache and log directory must be writable by the user/group that fpm is running as. Since you can't change the user that clears the cache, change the permissions on the directories so that files are created on behalf of the group/user.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question