Run WP-CLI as the Plesk subscription user instead of root
wp cli running as root warning | wp cli allow-root plesk | run wp cli as correct user | wp-cli | plesk | permissionsCaution: This command changes the system. Understand what it does before you run it.
runuser -u webuser -- wp plugin list --path=/var/www/vhosts/example.com/httpdocsStarts WP-CLI as the subscription’s system user, who owns the files under /var/www/vhosts/<domain>. This keeps newly created files such as uploads, plugins or caches under the right owner, so PHP-FPM can still write to them. stat -c %U on the httpdocs directory shows the subscription user.
Note: The alternative --allow-root works, but it runs plugin code with root privileges and leaves root-owned files behind. It should remain the exception.
Open question before approval: Prüfen, ob wp im PATH von runuser liegt (sonst vollen Pfad wie /usr/local/bin/wp angeben) und ob WP-CLI ohne HOME-Verzeichnis-Schreibrechte des Abo-Benutzers sauber läuft.
Also searched as
- wp cli running as root warning
- wp cli allow-root plesk
- run wp cli as correct user