I use EE to host multiple WP sites. I am trying to use wp-cli to keep them all updated automatically. I am running into a problem, however, which if I understand the EE conventions for permissions correctly (i.e., /var/www is owned by root:root; everything in www is owned by www-data:www-data) is as follows:
If I log in as root, I can run wp-cli successfully with the --allow-root flag on every command. However, doing plugin and theme updates this way changes the owner of directories and files in /plugins/ to root:root, which causes problems: some plugins fail altogether, and others work but fail to auto-update.
If I log in as a non root user, I cannot run wp-cli commands that require write permissions such as installing, updating, or removing plugins.
Can I solve this dilemma by (a) adding my non root user to the www-data group and (b) moving all of my websites from /var/www/ to a subfolder of my non root user’s home directory (e.g., /home/nonrootuser/websites/?
Or, do you recommend another solution that will allow me to run wp-cli as a non root user?