Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is WP-CLI incompatible with Bitnami's Wordpress install on AWS Lightsail?

Using a new instance of Wordpress on Ubuntu, I installed wp-cli via these instructions. I tried downloading the .phar package, chmodding it, etc.I also tried installing a .deb package. In both cases I get the same errors when running wp plugin update --all --debug:

Debug (bootstrap): No readable global config found (0.057s)
Debug (bootstrap): No project config found (0.057s)
Debug (bootstrap): argv: /usr/local/bin/wp plugin update --all --debug (0.057s)
Debug (bootstrap): ABSPATH defined: /opt/bitnami/apps/wordpress/htdocs/ (0.058s)
Debug (bootstrap): Begin WordPress load (0.058s)
Debug (bootstrap): wp-config.php path: /opt/bitnami/apps/wordpress/htdocs/wp-config.php (0.058s)
PHP Notice:  Undefined index: HTTP_HOST in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1070) : eval()'d code on line 90
PHP Notice:  Undefined index: HTTP_HOST in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1070) : eval()'d code on line 91
Debug (bootstrap): Loaded WordPress (0.188s)
Debug (bootstrap): Running command: plugin update (0.188s)
Downloading update from https://downloads.wordpress.org/plugin/akismet.4.0.zip...
Using cached file '/home/bitnami/.wp-cli/cache/plugin/akismet-4.0.zip'...
Unpacking the update...
Warning: Could not create directory.
Downloading update from https://downloads.wordpress.org/plugin/all-in-one-wp-migration.6.58.zip...
Using cached file '/home/bitnami/.wp-cli/cache/plugin/all-in-one-wp-migration-6.58.zip'...
Unpacking the update...
Warning: Could not create directory.
Downloading update from https://downloads.wordpress.org/plugin/all-in-one-seo-pack.2.4.2.zip...
Using cached file '/home/bitnami/.wp-cli/cache/plugin/all-in-one-seo-pack-2.4.2.zip'...
Unpacking the update...
Warning: Could not create directory.
Downloading update from https://downloads.wordpress.org/plugin/google-analytics-for-wordpress.6.2.4.zip...
Using cached file '/home/bitnami/.wp-cli/cache/plugin/google-analytics-for-wordpress-6.2.4.zip'...
Unpacking the update...
Warning: Could not create directory.
Downloading update from https://downloads.wordpress.org/plugin/jetpack.5.4.zip...
Using cached file '/home/bitnami/.wp-cli/cache/plugin/jetpack-5.4.zip'...
Unpacking the update...
Warning: Could not create directory.
+--------------------------------+-------------+-------------+--------+
| name                           | old_version | new_version | status |
+--------------------------------+-------------+-------------+--------+
| akismet                        | 3.3.4       | 4.0         | Error  |
| all-in-one-wp-migration        | 6.55        | 6.58        | Error  |
| all-in-one-seo-pack            | 2.3.15      | 2.4.2       | Error  |
| google-analytics-for-wordpress | 6.2.0       | 6.2.4       | Error  |
| jetpack                        | 5.2.1       | 5.4         | Error  |
+--------------------------------+-------------+-------------+--------+
Success: Plugins already updated.

I've run through the list of support options and I'm still unable to get wp-cli to work properly on AWS Lightsail, aka Bitnami. Looking at the github and wordpress.org forums, I see that lots of users have had some or all of the above errors. I tried all the suggested work-arounds:

  • wp-config.php: Wrap the ABSPATH line in a conditional.
  • wp-config.php: Move the add_filter() call into a MU plugin.
  • Several chmod and chown changes.

Some of these did make their respective errors go away, but wp still can't update plugins, etc.

Do I need to create the missing files identified in the PHP debug output?

Should I just not use AWS Lightsail/Bitnami? I really need wp-cli, so I'm willing to just move to ec2 or whatever else.

like image 903
Luke Sheppard Avatar asked Dec 24 '22 13:12

Luke Sheppard


2 Answers

I see two different issues there.

  1. You're using $_SERVER['HTTP_HOST'] in your wp-config.php file, which is not set while WP-CLI is being run. As WP-CLI is run as a command-line tool, some of the web-only PHP constants/variables are not set. You'll need to either set these manually or provide a conditional override.

  2. WordPress itself cannot create a directory in which to unpack the downloaded plugin archive files. This might be due to 1. above (as WordPress might be looking in the wrong location), or it might be an unrelated issue, like running WP-CLI with a different user that does not have the required permissions.

Both issues are not directly caused by WP-CLI, but rather the result of the particular setup of your WordPress installation.

like image 147
Alain Schlesser Avatar answered Dec 26 '22 02:12

Alain Schlesser


Bitnami Developer here.

Could you try running the commands as the user daemon?

 sudo su -s /bin/bash daemon

This is the user that has permission to write on the server

like image 32
Javier Salmeron Avatar answered Dec 26 '22 02:12

Javier Salmeron