cancel
Showing results for 
Search instead for 
Did you mean: 

Folder Permissions for magento2

Folder Permissions for magento2

Hello,

 

We want to know what are the exact folder permissions needed in production environment. At present for a dev environment we are using 777 to all folders. We want to know the correct way of folder access for magento2

 

Thanks
Dinesh

6 REPLIES 6

Re: Folder Permissions for magento2

Hello @dineshprim

 

Like in magento we don't gave 777 permission to all folders. Need to gave permission to only pub, var and generated only.

 

Magento 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.

777 for pub var and generated.

 

Also sharing a link below which will be helpful for you :

https://magento.stackexchange.com/questions/91870/magento-2-folder-file-permissions

 

If Issue Solved, Click Kudos/Accept As solutions.

Re: Folder Permissions for magento2

Hi @dineshprim

 

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 write access to the following files and directories: var,app/etc pub (and probably new in 2.2.x ) generated directories.

 

In addition, the web server's group must own the Magento file system so that the Magento user (who is 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.)

 

I recommend setting the permissions as follows:

 

770 permissions is required for all the directories.

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.

 

 

cd <your Magento install dir>
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 770 {} \; // 770 permission for var folder
find ./pub/media -type d -exec chmod 770 {} \;
find ./pub/static -type d -exec chmod 770 {} \;
chmod 770 ./app/etc
chmod 644 ./app/etc/*.xml
chown -R :<web server group> .
chmod u+x bin/magento

 


Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: Folder Permissions for magento2

This depends on your hosting or server environment. 

 

For servers that are more securely configured, they are usually set to 644 or 640 for files and 755 or 750 for directories. 

 

I wouldn't recommend using 666 or 777 as they are very insecure. 

Re: Folder Permissions for magento2

Thank you very much for your suggestions. I will try these options.

Re: Folder Permissions for magento2

Hi @dineshprim

 

Sure - try the options which mention above and let us know if you still face any issues on the same !

 

if issue solved,Click Kudos & Accept as Solution

Re: Folder Permissions for magento2

hi all

i tried all this options but that not success with me 

any suggessions please 

any one know where is the problem exactly please