About chmod issue

Here’s a breakdown in a little more detail

Reset Ownership and Group:
Run from any directory as superuser

sudo chown -R magento:www-data /var/www/html/

  • sudo: Run command with superuser privilege.
  • chown: Change owner
  • -R: Stands for “Recursively” (This means all Files and Folders contained within the directory)
  • magento:www-data: Owner:Group
  • /var/www/html/: Directory to make changes to

On a Ubuntu OS running Apache, the Group will always be www-data. However, the Owner will be whoever you created as your magento user.

Reset Folder and File Permissions:
Run from Magento root directory as magento user

find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && chmod u+x bin/magento

This command can consist of either 3 or 4 commands all strung together with “&&”:

  1. Find files in listed directories and update the permissions
    find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
  2. Find directories and update the permissions
    find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
  3. Change Group or everything to www-data (Not required if you’ve already run the chown command above)
    chown -R :www-data .
  4. Change File to be executable
    chmod u+x bin/magento
2 Likes