0

I accidentally run some magento's command as root user and some directories and files have messed up permissions.

Is there any way to reset the permissions because currently I'm getting errors such as:

UnexpectedValueException: The stream or file "/var/www/shop//var/log/system.log" could not be opened: failed to open stream: Permission denied in /var/www/shop/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:108 Stack trace: #0

Vrajesh Patel
  • 1,964
  • 2
  • 12
  • 28
BugHunterUK
  • 82
  • 13

1 Answers1

1

Assuming the following premises.

  1. Web server is runing with user:group www-data:web-data.
  2. Web server is running with umask 0002.
  3. Magento2 user:group is web:web.
  4. web user is also a member of www-data group.
  5. Magento2 installation directory is /var/www/shop.

Do these following changes, either as root or prefixed with sudo.

## We're setting a readable baseline, for all directories.  
chown web:www-data -R /var/www/shop
find /var/www/shop -type d -exec chown 2755 {} +

# These directories must be writable by both users. 
find ./var ./generated ./vendor ./pub/static ./pub/media ./app/etc -type d -exec chmod 2775 {} +
find ./var ./generated ./vendor ./pub/static ./pub/media ./app/etc -type f -exec chmod 0664 {} +
J. M. Becker
  • 213
  • 3
  • 14