How to set Magento 2 File and Folder Permissions

Owner of the Magento file system should be able to read/write/execute all files and folders.

The web server user must have write access to the following files and directories: var app/etc pub

We recommend setting the permissions as follows:

>> All directories have 770 permissions.

770 permissions give full control (that is, read/write/execute) to the owner and to the group and no permissions to anyone else.

>> All files have 660 permissions.

660 permissions mean the owner and the group can read and write but other users have no permissions.

You should set as bellow recommended.

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

If you still have any query regarding this “How to” or would like to add some suggestions to this solution, let us know your feedback or query at [email protected], and don’t forget to share this “How to” blog with your fellow Magento 2 users!