roots / trellis

WordPress LEMP stack with PHP 8.2, Composer, WP-CLI and more
https://roots.io/trellis/
MIT License
2.51k stars 607 forks source link

Bug: Provisioning fails on "Install WP" task #1354

Closed retlehs closed 2 years ago

retlehs commented 2 years ago

Description

What's wrong?

When provisioning a new server, the wordpress-install task fails at Install WP

What insights have you gained?

https://github.com/oerdnj/deb.sury.org/issues/1711

Possible solutions

Temporary workarounds

Switch to PHP 7.4 @ https://github.com/roots/trellis/blob/1dca397c8dbf9024d77d8e730e618824dcdd256c/group_vars/all/main.yml#L6

Steps To Reproduce

  1. Provision a Trellis server using PHP 8.0
  2. Server ends up installing PHP 8.1 and failing

Expected Behavior

  1. Server should install the proper version of PHP and provision without failure

Actual Behavior

Server installs PHP 8.1 and provisioning fails

Relevant Log Output

TASK [wordpress-install : Install WP] ******************************************
---------------------------------------------------
non-zero return code
Error: Your PHP installation appears to be missing the MySQL extension which
is required by WordPress.
failed: [default] (item=example.com) => {"ansible_loop_var": "item", "changed": true, "cmd": ["wp", "core", "install", "--allow-root", "--url=http://example.test", "--title=example.com", "--admin_user=admin", "--admin_password=mSdol9egGT7TqKN8Q3PxuODKAD4fo8Grg0bndqlqplqb0SecAKO6MvoeH9fkaOT0", "--admin_email=admin@example.test"], "delta": "0:00:00.214884", "end": "2022-01-18 22:11:53.183661", "item": {"key": "example.com", "value": {"admin_email": "admin@example.test", "cache": {"enabled": false}, "local_path": "../site", "multisite": {"enabled": false}, "site_hosts": [{"canonical": "example.test", "redirects": ["www.example.test"]}], "ssl": {"enabled": false, "provider": "self-signed"}}}, "rc": 1, "start": "2022-01-18 22:11:52.968777", "stderr_lines": ["Error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress."], "stdout": "", "stdout_lines": []}

Versions

1.12.0

tomektomczuk commented 2 years ago

So I actually have the same problem. I have changed trellis/group_vars/all/main.yml to 8.1 and provision production then I changed it back to 8.0 and I cannot deploy. I have disable install_recommends for php packages #1355 but it didn't fix the problem. I run Trellis 1.11.0

I've also tried a brand new staging. I have provision it without any problem but getting the following error on deploy (on both staging and production). Development works without any problems.

`non-zero return code PHP Deprecated: Return type of WP_Hook::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 498 PHP Deprecated: Return type of WP_Hook::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 511 PHP Deprecated: Return type of WP_Hook::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 524 PHP Deprecated: Return type of WP_Hook::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 537 PHP Deprecated: Return type of WP_Hook::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 548 PHP Deprecated: Return type of WP_Hook::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the

[\ReturnTypeWillChange] attribute should be used to temporarily suppress the

notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 440 PHP Deprecated: Return type of WP_Hook::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the

[\ReturnTypeWillChange] attribute should be used to temporarily suppress the

notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 454 PHP Deprecated: Return type of WP_Hook::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 468 PHP Deprecated: Return type of WP_Hook::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the

[\ReturnTypeWillChange] attribute should be used to temporarily suppress the

notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp- includes/class-wp-hook.php on line 485 Error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress. fatal: [164.90.179.180]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed", "--skip-plugins", "--skip-themes", "--require=/srv/www/staging.marcinkujanek.pl/shared/tmp_multisite_constants.php"], "delta": "0:00:00.160059", "end": "2022-01-20 17:05:31.745676", "failed_when_result": true, "rc": 1, "start": "2022-01-20 17:05:31.585617", "stderr_lines": ["PHP Deprecated: Return type of WP_Hook::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 498", "PHP Deprecated: Return type of WP_Hook::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 511", "PHP Deprecated: Return type of WP_Hook::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 524", "PHP Deprecated: Return type of WP_Hook::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 537", "PHP Deprecated: Return type of WP_Hook::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 548", "PHP Deprecated: Return type of WP_Hook::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 440", "PHP Deprecated: Return type of WP_Hook::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 454", "PHP Deprecated: Return type of WP_Hook::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 468", "PHP Deprecated: Return type of WP_Hook::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /srv/www/staging.marcinkujanek.pl/releases/20220120170412/web/wp/wp-includes/class-wp-hook.php on line 485", "Error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress."], "stdout": "", "stdout_lines": []} `

swalkinshaw commented 2 years ago

It's possible that fix doesn't work in all situations I guess.

Try manually running this: sudo update-alternatives --config php

If there's multiple PHP versions installed it will give you the choice to set the default.

tomektomczuk commented 2 years ago

It's possible that fix doesn't work in all situations I guess.

Try manually running this: sudo update-alternatives --config php

If there's multiple PHP versions installed it will give you the choice to set the default.

This has solved my problem. Thank you @swalkinshaw

slackday commented 2 years ago

I ran into the same problem changing to php 8.0 using sudo update-alternatives --config php works.

However I just provisioned the server and changed PHP version php_version: "8.0" in group_vars/all/main.yml and still got 8.1 when provisioning for the first time 🤔

tomektomczuk commented 2 years ago

I ran into the same problem changing to php 8.0 using sudo update-alternatives --config php works.

However I just provisioned the server and changed PHP version php_version: "8.0" in group_vars/all/main.yml and still got 8.1 when provisioning for the first time 🤔

You need to login to the server as a root and do sudo update-alternatives --config php

swalkinshaw commented 2 years ago

Yeah evidently https://github.com/roots/trellis/pull/1355 doesn't entirely fix this for some unknown reason. I think we'll need to handle the update-alternatives --config php part automatically in Trellis.

techieshark commented 2 years ago

Not sure if it warrants an additional bug report as it seems related… so I'll just comment here to say I also ran into an issue where a PHP extension was not available and this blocked the composer install on the Vagrant VM:

$ composer install … squizlabs/php_codesniffer 3.6.2 requires ext-simplexml * -> it is missing from your system. Install or enable PHP's simplexml extension

After vagrant ssh I ran php --ini and saw that PHP 8.1 was in use (despite having set php_version: "8.0" in trellis/group_vars/all/main.yml).

The workaround noted above worked; after the CLI version of PHP was set to 8.0, composer install worked as expected.


Update:

I also had to re-provision. So here's what I did, from the top:

$ trellis up # This will fail part way through due to the bug discussed in issue #1354
$ vagrant ssh 
# Then, on the VM:
$ sudo update-alternatives --set php /usr/bin/php8.0
# then exit the VM and run this on the host:
$ trellis provision development