Blog / WordPress/ How to Fix WordPress Errors Caused by Missing PHP 8 Extensions in BT Panel

How to Fix WordPress Errors Caused by Missing PHP 8 Extensions in BT Panel

宝塔面板安装WordPress报错?缺失PHP 8扩展的修复方案

Problem Description

When installing or running WordPress in BT Panel (BaoTa), you may encounter errors due to missing PHP extensions. Common error messages include:

  • Call to undefined function mysqli_connect()
  • Your PHP installation appears to be missing the MySQL extension which is required by WordPress
  • Errors indicating missing mbstring or openssl extensions.

These errors are typically caused by the absence of core PHP extensions required by WordPress, especially when using PHP 8.x. This guide will show you how to quickly check and install the missing extensions via BT Panel.

Solution: Install Missing PHP Extensions

Follow these steps to install the necessary extensions for your PHP environment.

Step 1: Log into BT Panel and Access PHP Settings

  1. Log into your BT Panel backend.
  2. In the left navigation bar, find and click "Software Store".
  3. In the list of installed software, find the PHP version your website is using (e.g., PHP-8.0, PHP-8.1) and click its corresponding "Settings" button.

Step 2: Install Extension Modules

  1. On the PHP management page, click the "Install Extensions" tab at the top.
  2. In the extension list, find and select the core extensions required for WordPress. For most WordPress sites, the following are essential:
    • mysqli or pdo_mysql: For connecting to the MySQL database (install one or both; both are recommended).
    • fileinfo: For file type detection, required by many themes and plugins.
    • opcache: PHP performance accelerator, recommended for installation.
    • exif: For processing image metadata.
    • mbstring: Multibyte string support, essential for handling non-English characters.
    • openssl: For HTTPS secure connections and API communication.
  3. After selecting the required extensions, click the "Submit" button at the bottom. BT Panel will automatically download and compile these extensions.
  4. After installation, you must restart the PHP service. You can do this in the "Service" tab of the PHP management page or by returning to the BT Panel homepage, finding the PHP service, and clicking restart.

Step 3: Verify Successful Extension Installation

After installing and restarting, confirm the extensions are loaded.

  1. On the PHP management page, click the "Configuration File" tab.
  2. Use the search function (Ctrl+F) to search for extension= and check if the relevant configuration lines are uncommented (no semicolon ; at the beginning). BT Panel usually handles this automatically.
  3. A more direct method is to create a PHP info file for verification:
    • Via the BT Panel "Files" manager, navigate to your website's root directory (e.g., /www/wwwroot/yourdomain.com).
    • Create a new file named phpinfo.php.
    • Edit the file and insert the code:
      <?php
      phpinfo();
      ?>
    • Save the file and access it via your browser at https://yourdomain.com/phpinfo.php.
    • On the opened page, search for keywords like mysqli or mbstring. If the corresponding extension section exists, the installation was successful.
    • Important: After verification, be sure to delete the phpinfo.php file to prevent server information leakage.

Common Issues and Notes

  • Extension Installation Fails: If errors occur during installation, it may be due to missing compilation dependencies or insufficient disk space. Check disk space in the BT Panel "Linux Toolbox" or install compilation tools via SSH with yum install -y gcc gcc-c++ make (for CentOS) and try again.
  • WordPress Still Reports Errors: Ensure your website configuration (in BT Panel's "Websites" settings) is using the PHP version you just installed extensions for. Sometimes extensions are installed but the website still points to an old PHP version.
  • Caching Issues: After restarting the PHP service, if the problem persists, try clearing WordPress cache, OPcache (if installed), and your browser cache.
  • Extension Selection: Beyond the core extensions listed, you may need to install others like imagick (image processing), zip, or gd depending on your theme or plugins. Install based on specific error messages.

Summary

To fix WordPress errors caused by missing PHP extensions in BT Panel, the core steps are: Locate the PHP version -> Install extensions -> Restart service -> Verify activation. Following the steps in this guide will quickly resolve most missing extension issues. Maintaining complete PHP extensions is fundamental for the stable operation of a WordPress site.

Post a Comment

Your email will not be published. Required fields are marked with *.