The following PHP extensions are required but are not installed on my server: gd, pdo_mysql, and mbstring. How can I install these extensions on my server?

Updated: Feb 22, 2025

The following PHP extensions are required but are not installed on my server: gd, pdo_mysql, and mbstring. How can I install these extensions on my server?

To install the required PHP extensions (gd, pdo_mysql, and mbstring) on your server, you will need to follow these general steps, which may vary slightly depending on your specific server environment:

  1. Check your PHP version: Before installing the extensions, make sure you know the version of PHP installed on your server. You can check this by running the following PHP code snippet in a new file (e.g., phpinfo.php) and accessing it in your web browser:
<?php
phpinfo();
?>
  1. Contact your hosting provider: If you're using a shared hosting plan, you'll likely need to contact your hosting provider's support team to request the installation of these extensions. Provide them with the names of the extensions (gd, pdo_mysql, and mbstring) and your PHP version. They may be able to install the extensions for you or provide you with instructions on how to do it yourself.

  2. Install the extensions using cPanel or SSH: If you have root access to your server or use a control panel like cPanel, you can install the extensions yourself. Here's a general outline of the process for each extension:

    a. gd extension: i. For cPanel: Go to the Software section, find and click on "Select PHP Versions." Choose your PHP version and then click on "Switch to PHP Options." Scroll down and find the "gd" section. Set the "gd" value to "on" and click "Apply." ii. For SSH: Install the GD library using the package manager for your operating system. For example, on Ubuntu, you can use the following command:

      ```
      sudo apt-get install php-gd
      ```
    

    b. pdo_mysql extension: i. For cPanel: Go to the Software section, find and click on "Select PHP Versions." Choose your PHP version and then click on "Switch to PHP Options." Scroll down and find the "PDO" section. Set the "pdo_mysql" value to "on" and click "Apply." ii. For SSH: Install the pdo_mysql extension using PECL (PHP Extension Community Library). First, make sure you have PECL installed by running:

      ```
      sudo apt-get install php-pear
      ```
    
      Then, install the pdo_mysql extension using the following command:
    
      ```
      sudo pecl install pdo_mysql
      ```
    
      After the installation, enable the extension by editing the php.ini file:
    
      ```
      sudo nano /etc/php/<your_php_version>/php.ini
      ```
    
      Add the following line at the end of the file:
    
      ```
      extension=pdo_mysql.so
      ```
    
      Save and exit the file, then restart your PHP service.
    

    c. mbstring extension: i. For cPanel: Go to the Software section, find and click on "Select PHP Versions." Choose your PHP version and then click on "Switch to PHP Options." Scroll down and find the "mbstring" section. Set the "mbstring" value to "on" and click "Apply." ii. For SSH: Install the mbstring extension using PECL. First, make sure you have PECL installed by running:

      ```
      sudo apt-get install php-pear
      ```
    
      Then, install the mbstring extension using the following command:
    
      ```
      sudo pecl install mbstring
      ```
    
      After the installation, enable the extension by editing the php.ini file:
    
      ```
      sudo nano /etc/php/<your_php_version>/php.ini
      ```
    
      Add the following line at the end of the file:
    
      ```
      extension=mbstring.so
      ```
    
      Save and exit the file, then restart your PHP service.
    
  3. Verify the installation: After installing the extensions, make sure they are enabled by checking the "Loaded Configuration File" section in your phpinfo.php output. The extensions should be listed there. If not, double-check your php.ini file and restart your PHP service.