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
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
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.
www-data
runs the web server. But the cache files are created by the ubuntu
user.
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