WP-CLI error using sudo
Hello,
I've installed wp-cli using yum.
Now, when I try to execute a wp command as a cpanel user (being
the : [CODE=bash]cd /home/some_user/public_html/ sudo -u some_user wp plugin list
I get the following error: [CODE=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: [CODE=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
/home/some_user/public_html/the : [CODE=bash]cd /home/some_user/public_html/ sudo -u some_user wp plugin list
I get the following error: [CODE=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: [CODE=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
-
Hey there! Can you try this simple one-liner to confirm that your sudo access in general is working properly for that user? 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.0 -
Thank you for your reply. When I run this with an existing user I get: I am theuser, with uid 1002
If I run it with a dummy user name I get:sudo: unknown user: otheruser sudo: unable to initialize policy plugin0 -
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: 0 -
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. 0 -
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.
I've installed the nightly build, but it keeps showing me errors:? sudo -i -u user wp info 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 41 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 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
I've found that php root's path differs from php user's path. See:? sudo -i -u user php -v PHP 7.4.15 (cgi-fcgi) (built: Feb 26 2021 12:25:40) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.15, Copyright (c), by Zend Technologies ? php -v PHP 7.4.15 (cli) (built: Feb 26 2021 12:25:36) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.15, Copyright (c), by Zend Technologies
So, user isn't using php-cli but php-fcgi. Could this be the problem? How can I change to all users, php path? environment variable? Regards, Mauricio0
Please sign in to leave a comment.
Comments
5 comments