Articles in this section

WP Toolkit shows WordPress instance as broken when a domain is using Alt-PHP: Error establishing a database connection

kb: bug Plesk for Linux ext: wptk ABT: Group B

Applicable to:

  • Plesk for Linux

Symptoms

  • Plesk is installed on a CloudLinux server.

  • When installing WordPress via WP Toolkit, the operation fails with the following error message:

    PLESK_ERROR: 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:

      PLESK_ERROR: 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:

      CONFIG_TEXT: ERR [extension/wp-toolkit] Failed to reset cache for the instance #X, reason: Error establishing a database connection.

Cause

This was reported as a WP Toolkit bug with ID EXTWPTOOLK-4371 and in the scope of PPP-52061 (Plesk 18.0.36) default configuration of Alt-PHP was adjusted to comply with Plesk needs.

PHP extensions like json.so and mysqli.so for Alt-PHP are disabled.

Resolution

Apply one of the following workarounds:

 

Create a symbolic link for mysql socket

 

  1. Connect to the Plesk server via SSH.

  2. Create a symbolic link:

    # ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

 

Enable additional extensions in PHP configuration

 

  1. Log in to Plesk.

  2. Go to Domains > example.com > PHP Settings.

  3. Add the following lines to the Additional configuration directives field:

    CONFIG_TEXT: extension=json.so
    extension=mysqli.so
    extension=pdo_mysql.so

    Note: 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.

 

Change Alt-PHP to PHP provided by Plesk

 

  1. Log in to Plesk.

  2. Go to Domains > example.com > PHP Settings.

  3. Change PHP handler to any non Alt-PHP.

  4. Go to Domains > example.com > WordPress.

  5. On the affected WordPress instance, click Screenshot_2020-06-03_Plesk_Obsidian_18_0_25.png > Detach.

  6. Click Scan to detect the instance.

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.