I'm trying to run the following command locally:

/usr/local/bin/wp plugin deactivate "EG Fulltext Search" --allow-root

And I get the error undefined function apache_request_headers()

Here is the wp info:

PHP binary:     /usr/bin/php
PHP version:    5.5.37
php.ini used:   /etc/php.ini
WP-CLI root dir:        phar://wp-cli.phar
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 0.24.0-alpha-95a84de

This is running apache on Centos 7. Php is running as Apache 2.0 Handler.

I used the nightly version but I also get this error the latest stable release.

I'm really stuck on this at the moment and can't use the wp commands so any help would be really appreciated.

  • Shouldn't you be using the plugin slug rather than a human readable name? Jul 22 '16 at 16:31
  • Thanks Andy! You're right I had to use the slug to make it work as well.
    – iFunky
    Jul 30 '16 at 10:48

From quick search I cannot find calls of this function in neither WP core or WP CLI.

From quick check of documentation for it it seems that support for it in CLI context is (relatively) recent — starting with PHP 5.5.7.

You might want to check if your PHP up to date. Note that CLI might be running different/older PHP version from web server.

  • Thanks, you pointed me in the right direction. I found the apache call in wp-config.php which was setting variables based on the x-forward-proto header existing. I wrapped the code in a if function exists block and it works now! :-)
    – iFunky
    Jul 30 '16 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.