1

What are the correct Magento permissions and how can one set them correctly?

2 Answers 2

1

no special permissions, you just make sure that files owned by user who runs php or in case of cPanel - cpanel user and group

just update files owner:

cd /home/user
chown -R user:user public_html

find public_html -type f -exec chmod -c 640 {} \;
find public_html -type d -exec chmod -c 2750 {} \;

cd /home/user/public_html
find var generated pub/static pub/media -type d -exec chmod 2770 {} \;
find var generated pub/static pub/media -type f -exec chmod 660 {} \;

chmod u+x bin/magento

instead of changing permissions everytime, login / work as proper user, files owner, from root to php user:

cd /home/user/public_html/
su $(stat -c '%U' index.php) -s /bin/bash
whoami
pwd

when you add cron, always place it in users crontab, not in root!

su $(stat -c '%U' index.php) -s /bin/bash
php bin/magento cron:install --force
0

Magento 2 recommended folder and file permission

Please follow following terminal commands for folder and file permission.

find . -type f -exec chmod 644 {} \;

find . -type d -exec chmod 755 {} \;

find var pub/static pub/media  generated/ app/etc -type f -exec chmod g+w {} \;

find var pub/static pub/media generated/ app/etc -type d -exec chmod g+ws {} \;

chmod u+x bin/magento

For more details refer https://devdocs.magento.com/guides/v2.3/config-guide/prod/prod_file-sys-perms.html

1
  • Did you try this solution? Commented Jun 20, 2019 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.