Magento 2 Folder/File Permissions

- Magento 2

Magento 2 Development; Magento 2 tutorial

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:

Unfortunately, things are a little bit more complicated in Magento 2, so that the aforementioned command is no longer useful. Always check DevDocs to find the answer to your questions. Although the documentation is huge, you will always find the solution of your problems; but since you are already here, we’d like to help you understand core nuances of Magento 2 file and folder permissions.

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:

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:

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 StackExchange question by Neekoy and answers by Denish Vachhani and Daniel van der Garde. For more useful articles, check out our Cookbook.