Magento – Magento 2 Development permissions issue

magento2permissions

I'm currently developing a Magento 2 site, but I'm having quite a lot of issues with permissions/ownership.

I'm running Magento on a VPS, and I have followed Magentos official documentation for multiple users, not shared hosting.

Currently, I have these users:

  • root (Web server root)
  • user (part of the sudoers file)
  • Magento (Magento filesystem user – Is there any way I can double check/change this?) Also part of www-data group
  • sftp (My SFTP, locked into /var/www/html)

When I try and upgrade from 2.1.2 to 2.1.3, I get the error :

Fatal error: Interface 'Psr\Log\LoggerInterface' not found in
/var/www/html/magento/update/vendor/monolog/monolog/src/Monolog/Logger.php
on line 27

The file in that directory is there, with 775 permissions for magento:www-data. I have tried user:www-data, magento:www-data .. etc.

My Cron job also fails, it only works via CLI if I append sudo before the commend – I believe this is permissions related too. This fails with the error:

Command line user does not have read and write permissions on
var/generation directory. Please address this issue before using
Magento command line." – This has 775 permissions, recursive through
the /var/ dir.

I'm using:

  • Ubuntu 14.04.1 LTS x64
  • PHP 7.0.11-1
  • MySQL 5.6.33
  • Apache/2.4.7

Aside from chmod 777, I don't know what else to do. I believe that my Magento 2 isn't using the Magento user – how can I check?

Thanks for your time

Best Answer

Try fix permissons by commands below

sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; && sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; && sudo chown -R $USER:www-data . && sudo chmod u+x bin/magento
sudo find var pub/media pub/static -type d -exec chmod g+ws {} \;
sudo find var pub/media pub/static -type f -not -name .htaccess -exec chmod g+w {} \;
sudo find -L vendor/bin -type f -exec chmod u+x {} \;
Related Topic