Magento 2 Folder/File Permissions
If you have no ideas about what to do with permissions on your Magento 2 installation or they are messed up, you’ve come to the right place. Below, we discuss Magento 2 file and folder permissions and shed light on how to use them properly.
You might have run the following command on older Magento versions to make folders 755 and files 644:
1 |
find . -type f -exec chmod -c 644 {} \; && find . -type d -exec chmod -c 755 {} \; |
Unfortunately, things are a little bit more complicated in Magento 2, so that the aforementioned command is no longer useful. Always check
There are several important things that we should mention here. As the owner of the Magento 2 file system, you must have the full control over all files and directories. Under the full control, we mean that you should be able to read, write, and execute without any limits.
At the same time, you shouldn’t be a web server user. It should be a different user to cope with Magento 2 file/folder permissions.
As for the web server user, he/she must have write access to var app/etc pub. And don’t forget that the web server’s group must own the Magento file system. It will let the Magento user share access to files with the web server user.
As for permissions, they are the following:
- 770 – the permission for all directories in Magento 2: it provides the full permission to the owner and group, others get no permissions;
- 660 – the permission for all files: the owner and group can read and write, others get no permissions.
In some cases, 770 and 660 cannot be used. Then, you should use 755 and 644 instead. Run the following command to apply new permissions:
1 |
find . -type d -exec chmod 755 {} \; && find . -type f -exec chmod 644 {} \; && chmod u+x bin/magento |
Also note that the newly generated files will have the default permissions again: 770 and 660. To edit those default chmod values, go to the following files:
1 2 3 4 5 |
/vendor/magento/framework/Filesystem/DriverInterface.php (WRITEABLE_DIRECTORY_MODE and WRITEABLE_FILE_MODE) /lib/internal/Cm/Cache/Backend/File.php (directory_mode and file_mode) |
Apply changes and run the first command again to avoid changes related to the newly generated files.
We hope this article was useful. It is based on the