What are the correct file permission settings for magento 2.2 on a single-user production environment?
-
21-01-2021 - |
Question
I am setting up a Magento 2.2.5 instance on a production environment (single-user / shared hosting). When it comes to file permissions, I found two documentation pages:
- https://devdocs.magento.com/guides/v2.2/install-gde/prereq/file-system-perms.html
- https://devdocs.magento.com/guides/v2.2/config-guide/prod/prod_file-sys-perms.html
When following the instructions for a shared hosting environment at the first link, everything is fine. But, I assumed I had to follow the instructions at the second link as well since I am configuring a production environment. As soon as I run the command to "Make code files and directories read-only", I get an error like this: Backend fatal error: PHP Fatal error: Uncaught Zend_Cache_Exception
, because cache_dir var/page_cache
is not writable.
This seems logical since the command made var
read-only.
So, is the documentation wrong? Or should I somehow only follow the documentation at the first link, not the second?
Solution
Here's an explanation of what each folder does in var: https://devdocs.magento.com/guides/v2.2/howdoi/php/php_clear-dirs.html
It makes sense that view_preprocessed folder is made read only after the files have been generated. It also makes sense that the generated folder is write only after its generated, but some things can't be read only in var (example: logs).
Looks like a devdocs mistake with the command not doing what the best practice describes above it.