Magento 2 file/folder permissions setting

Magento 2 has a big change compared to Magento 1. Therefore, Magento 1 users have little difficulty when switching to Magento 2. What are the correct file and folder permissions for Magento 2 and How to set Magento 2 file/folder permissions?

We recommend setting the permissions of file/folder in Magento 2 as below:

  • All directories have 770 permissions.
  • 770 permissions give full control (read/write/execute) to the owner and to the group and no permissions to anyone else.
  • All files have 660 permissions.
  • 660 permissions means the owner and the group can read and write but other users have no permissions.

That's mean:

  • The owner of the Magento file system: Must have full control (read/write/execute) of all files and directories.
  • Must not be the web server user; it should be a different user.
  • The web server user must have to write access to the following files and directories: var app/etc pub
  • In addition, the web server's group must own the Magento file system so that the Magento users (who are in the group) can share access to files with the web server user. (This includes files created by the Magento Admin or other web-based utilities.)

Setting file/folder commands in Magento 2

find . -type f -exec chmod 644 {} \;                        // 644 permission for files

find . -type d -exec chmod 755 {} \;                        // 755 permission for directory 

find ./var -type d -exec chmod 777 {} \;                // 777 permission for var folder    

find ./pub/media -type d -exec chmod 777 {} \;

find ./pub/static -type d -exec chmod 777 {} \;

chmod 777 ./app/etc

chmod 644 ./app/etc/*.xml

That’s all information as well as manipulations about file/folder permissions setting in Magento 2. Hope that they are useful for you.

Thanks for reading!

Find out the latest MageHit's Magento 2 extensions: Here