1

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

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

  • Did you try this solution? – MSA Jun 20 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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