Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp-cli not working for Debian WordPress installations? #2157

Closed
bbrdaric opened this issue Oct 16, 2015 · 5 comments
Closed

wp-cli not working for Debian WordPress installations? #2157

bbrdaric opened this issue Oct 16, 2015 · 5 comments

Comments

@bbrdaric
Copy link

bbrdaric commented Oct 16, 2015

Hello,

I have WordPress installation that's installed from Debian's oldstable (Wheezy) repository that uses Debian customized wp-config.php.

bbrdaric@srv:/usr/share/wordpress$ wp --info
PHP binary:     /usr/bin/php5
PHP version:    5.4.45-0+deb7u1
php.ini used:   /etc/php5/cli/php.ini
WP-CLI root dir:        phar://wp-cli.phar
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 0.21.0-alpha-9a90e8b

When I try to run wp-cli, I get this

bbrdaric@srv:/usr/share/wordpress$ wp theme list --debug
Debug: No readable global config found (0.011s)
Debug: No project config found (0.012s)
Debug: ABSPATH defined: /usr/share/wordpress/ (0.029s)
Debug: Begin WordPress load (0.03s)
Debug: wp-config.php path: /usr/share/wordpress/wp-config.php (0.03s)
PHP Notice:  Undefined index: HTTP_HOST in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(731) : eval()'d code on line 10
Neither <b>/etc/wordpress/config-.php</b> nor <b>/etc/wordpress/config-.php</b> could be found. <br/> Ensure one of them exists, is readable by the webserver and contains the right password/username.

Any ideas how to get it working?

@danielbachhuber
Copy link
Member

$_SERVER['HTTP_HOST'] isn't set, so your file lookup isn't working: https://sources.debian.net/src/wordpress/3.6.1%2Bdfsg-1~deb7u6/debian/wp-config.php/#L11

You can specify --url when you run wp theme list, or you define it in a project or global config.

Alternatively, you can edit wp-config.php to load the right file, instead of doing a fancy lookup based on $_SERVER['HTTP_HOST']

@bbrdaric
Copy link
Author

bbrdaric commented Oct 16, 2015

Hmm, good idea, tried that also (editing wp-config.file to remove fancy lookup), but then it clashes with domain mapping plugin

bbrdaric@srv:/usr/share/wordpress$ wp themes list --debug
Debug: No readable global config found (0.01s)
Debug: No project config found (0.011s)
Debug: ABSPATH defined: /usr/share/wordpress/ (0.012s)
Debug: Begin WordPress load (0.012s)
Debug: wp-config.php path: /usr/share/wordpress/wp-config.php (0.012s)
PHP Warning:  Creating default object from empty value in /usr/share/wordpress/wp-content/sunrise.php on line 10
PHP Fatal error:  Call to undefined method stdClass::escape() in /usr/share/wordpress/wp-content/sunrise.php on line 11

@imran-uk
Copy link

Same issue, I bypassed this by simplifying the filename selection like this:

/* Look up a host-specific config file in
  * /etc/wordpress/config-<host>.php or /etc/wordpress/config-<domain>.php
  */
 //$debian_server = preg_replace('/:.*/', "", $_SERVER['HTTP_HOST']);
 //$debian_server = preg_replace("/[^a-zA-Z0-9.\-]/", "", $debian_server);
 //$debian_file = '/etc/wordpress/config-'.strtolower($debian_server).'.php';
 /* Main site in case of multisite with subdomains */
 //$debian_main_server = preg_replace("/^[^.]*\./", "", $debian_server);
 //$debian_main_file = '/etc/wordpress/config-'.strtolower($debian_main_server).'.php';

 $debian_file = '/etc/wordpress/config-<actual name of file>.php';

@hugovolzoliveira
Copy link

Thanks, your solution was perfect!

@imran-uk
Copy link

imran-uk commented Jul 30, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants