Operating System & Version
CentOS Linux release 7.9.2009
cPanel & WHM Version
92.06

mlopez

Member
Dec 17, 2020
16
4
3
iAiOxJi78`
cPanel Access Level
Root Administrator
Hello,

I've installed wp-cli using yum.

Now, when I try to execute a wp command as a cpanel user (being /home/some_user/public_html/ the :

Bash:
cd /home/some_user/public_html/
sudo -u some_user wp plugin list
I get the following error:

Bash:
PHP Warning:  Use of undefined constant STDOUT - assumed 'STDOUT' (this will throw an Error in a future version of PHP) in phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/utils.php on line 1057
PHP Warning:  Use of undefined constant STDERR - assumed 'STDERR' (this will throw an Error in a future version of PHP) in phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Regular.php on line 50
PHP Warning:  fwrite() expects parameter 1 to be resource, string given in phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Base.php on line 64
Content-type: text/html; charset=UTF-8
The only way I can issue a wp command is changing the user before, like this:
Bash:
cd /home/some_user/public_html/
su some_user
wp plugin list
exit
What should I do to allow wp to work with sudo?

Thanks in advance

Mauricio
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
3,036
379
243
cPanel Access Level
Root Administrator
Hey there! Can you try this simple one-liner to confirm that your sudo access in general is working properly for that user?

Code:
sudo -H -u otheruser bash -c 'echo "I am $USER, with uid $UID"'
Just replace the "otheruser" name with the actual username of the account you are working with to test this.
 

mlopez

Member
Dec 17, 2020
16
4
3
iAiOxJi78`
cPanel Access Level
Root Administrator
Thank you for your reply.

When I run this with an existing user I get:
Code:
I am theuser, with uid 1002
If I run it with a dummy user name I get:
Code:
sudo: unknown user: otheruser
sudo: unable to initialize policy plugin
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
3,036
379
243
cPanel Access Level
Root Administrator
That sounds correct to me - that's what I would expect to happen, and indicates the sudo access itself is working well.

When you did the initial wp-cli installation, was that work performed as root or as a cPanel user? It might be worth reading through the details listed here since you are running into odd behavior with that tool:

 

splaquet

Well-Known Member
Sep 24, 2008
52
3
58
W. Hartford, CT
cPanel Access Level
Root Administrator
Twitter
i do believe that the latest wp-cli release has conflicts with php7.4.

run this: (i'm exhausted, but i think this is it. it's the --nightly part that's important.)
wp cli update --nightly

that'll install the latest nightly build, which *is* 7.4 compatible.