su -
su -s /bin/bash wwwdev
cd /path/to/wordpress
/usr/local/bin/wp (stuff)
I start with su -
because I don’t know the passwords for the restricted IDs, but i do know the password for root. /usr/local/bin/wp is a soft link to /usr/local/bin/wp-cli.phar
Error: YIKES! It looks like you’re running this as root. You probably meant to run this as the user that your WordPress install exists under.
If you REALLY mean to run this as root, we won’t stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.
If you’d like to continue as root, please run this again, adding this flag: –allow-root
If you’d like to run it as the user that this site is under, you can run the following to become the respective user:
sudo -u USER -i — wp <command>
]]> sudo -u USER -i -- wp <command>
…So the message implies that USER must be a defined user in the WordPress Site but I’m not clear on whether USER needs to be a defined user on the Linux Host also. Of course it’s possible to have a username on the Linux Host that matches the WordPress Site Username. However I was actually running this in a script performing identical operations on eight different wordpress installations (located on the same server) so for this to work they would all need to have one identical username. That’s do-able of course.
I’ll probably try this out shortly …would still be interested to hear input from anyone else who tries it.
Also: I have noticed that apparently it might not be necessary in any case to have the user in the /etc/sudoers file after all.
]]>