Symptoms
Plesk is installed on a CloudLinux server.
When installing WordPress via WP Toolkit, the operation fails with the following error message:
PHP Fatal error: Uncaught Error: Call to undefined function json_encode() in /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/wp-cli/vendor/mustache/mustache/src/Mustache/Engine.php:637
When scanning or refreshing a WordPress instance in WP Toolkit, one of the following happens:
the operation completes with the following error message and the instance is marked as broken:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress. PHP Fatal error: Uncaught Error: Call to undefined function json_encode() in /usr/local/psa/admin/plib/modules/wp-toolkit/vendor/wp-cli/wp-cli/php/class-wp-cli.php:742
the instance is marked as broken and the following error message appears in
/var/log/plesk/panel.log:ERR [extension/wp-toolkit] Failed to reset cache for the instance #X, reason: Error establishing a database connection.
Cause
PHP extensions like json.so and mysqli.so for Alt-PHP are disabled.
Resolution
Apply one of the following workarounds:
Connect to the Plesk server via SSH.
Create a symbolic link:
# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Go to Domains > example.com > PHP Settings.
Add the following lines to the Additional configuration directives field:
extension=json.so
extension=mysqli.so
extension=pdo_mysql.soNote: If the error "Module 'mysqli' already loaded at Unknown#0" is shown when accessing domains, disable the above extensions at Domains > example.com > PHP Selector.
Go to Domains > example.com > PHP Settings.
Change PHP handler to any non Alt-PHP.
Go to Domains > example.com > WordPress.
On the affected WordPress instance, click
> Detach.
Click Scan to detect the instance.