0

I am following the standard deploy procedure for single machines except I am clearing the static folder as well as clearing and flushing cache.

I am forced to run sudo chown -R www-data:www-data var/cache

2 Answers 2

1

Deployment steps:

Log in to your production server as, or switch to, the Magento file system owner.

this is because you run commands as another user, not the owner. to run it properly you either need to switch user or run command as php user:

su PHP_USER -s /bin/bash -c "bin/magento setup:upgrade"

if you run command like this you will see:

[root@admin ~]# whoami
root
[root@admin ~]# su php_user -s /bin/bash -c "whoami"
php_user

but before properly chmod your files, for example :

chown -R php_user:php_user * magento_folder
find . -type f -exec chmod 660 {} \;
find . -type d -exec chmod 2770 {} \;

php_user the user who owns php process.

1
  • In my case www-data runs the web server. But the cache files are created by the ubuntu user.
    – tread
    Commented May 8, 2017 at 11:14
1

So I found the reason this was failing

It was the cronjob

I set up the cronjob as another user, when I should have used www-data

Like so: sudo crontab -u www-data -e

and then added the Magento 2 cronjobs

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.