How to Install Essential PHP Extensions for WordPress Using WHM/cPanel (Including Exif, Fileinfo, Imagick, PHP-Intl, and More)

Learn how to install essential PHP extensions such as Exif, Fileinfo, Imagick, PHP-Intl, and more for WordPress using WHM/cPanel. Includes details on managing PHP extensions by version and enhancing performance with Memcached and Redis.
WHM/cPanel interface with PHP logos for Exif, Fileinfo, Imagick, PHP-Intl, and Memcached and Redis logos.

As WordPress continues to evolve, it’s crucial to optimize your PHP environment with the correct extensions. As of September 2024, PHP 8.2 is the recommended version, with PHP 8.3 now available as the latest stable release. This guide covers how to install essential PHP extensions such as Exif, Fileinfo, Imagick, PHP-Intl, and also how to enhance your WordPress performance by integrating Memcached and Redis. We’ll also discuss the importance of keeping your server updated with the latest PHP versions and how to manage extensions per PHP version using EasyApache 4.


Table of Contents

  1. Prerequisites
  2. Essential PHP Extensions for WordPress
  3. Why PHP 8.2 or PHP 8.3 Should Be Your Target
  4. Installing PHP Extensions Using EasyApache 4
  5. Enhancing Performance with Memcached and Redis
  6. Installing PHP Extensions for Memcached and Redis
  7. Verifying Installed Extensions
  8. Common Issues and Troubleshooting
  9. Conclusion

1. Prerequisites

Ensure that you have the following before starting:

  • WHM/cPanel installed on your server.
  • Root access to the server.
  • PHP installed and managed through EasyApache 4.

2. Essential PHP Extensions for WordPress

The following PHP extensions are recommended for optimal WordPress functionality:

  • Exif: Necessary for image orientation detection.
  • Fileinfo: Required for detecting file types during uploads.
  • Imagick: Advanced image processing library.
  • GD: Basic image processing library.
  • Mbstring: Handles multibyte strings, crucial for non-English content.
  • CURL: Essential for external API calls.
  • ZIP: Required for uploading and extracting compressed files.
  • OpenSSL: Enables secure communication.
  • Intl (PHP-Intl): Required for internationalization and localization, handling date and time formats, translations, and more.

3. Why PHP 8.2 or PHP 8.3 Should Be Your Target

As of September 2024, WordPress users should be running PHP 8.2 or considering an upgrade to PHP 8.3. Here’s why:

  • PHP 8.2 was released in December 2022 and remains under active support until December 2024 and security support until December 2025.
  • PHP 8.3 was released in November 2023 and is under active support until November 2025 and security support until November 2026.
  • PHP 8.1 is approaching the end of its security support in November 2024, making it essential to plan for an upgrade.

Staying updated with the latest PHP versions ensures better performance, security, and access to new features.

BranchInitial ReleaseActive Support UntilSecurity Support Until
8.125 Nov 202125 Nov 2023 (ended)25 Nov 2024
8.208 Dec 202208 Dec 202408 Dec 2025
8.323 Nov 202323 Nov 202523 Nov 2026

4. Installing PHP Extensions Using EasyApache 4

Using EasyApache 4 within WHM is the simplest method for installing and managing PHP extensions across different PHP versions. In EasyApache 4, extensions are installed per PHP version, so you’ll need to select the extensions for each version you are using. Here’s how to install key extensions like Exif, Fileinfo, Imagick, and PHP-Intl.

Step 1: Log in to WHM

Navigate to https://your-server-ip:2087/ and log in using your root credentials.

Step 2: Open EasyApache 4

Search for EasyApache 4 in the WHM dashboard and click on it.

Step 3: Customize PHP Extensions for PHP 8.2 or 8.3

  • Click Customize next to your active profile.
  • In the left-hand menu, select PHP Extensions.

Step 4: Install Required Extensions

For each PHP version (e.g., PHP 8.2, PHP 8.3) you are using, search for the following extensions and enable them by checking the corresponding boxes:

  • php8.2-exif or php8.3-exif
  • php8.2-fileinfo or php8.3-fileinfo
  • php8.2-imagick or php8.3-imagick
  • php8.2-intl or php8.3-intl
  • php8.2-gd or php8.3-gd
  • php8.2-mbstring or php8.3-mbstring
  • php8.2-curl or php8.3-curl
  • php8.2-zip or php8.3-zip
  • php8.2-openssl or php8.3-openssl

Step 5: Provision the Changes

After selecting the necessary extensions, click Review and then Provision to apply the changes. This will install the selected extensions for the specified PHP versions.


5. Enhancing Performance with Memcached and Redis

To further optimize your WordPress site, you can implement caching mechanisms like Memcached and Redis. These tools help reduce database load and improve site performance. Installing them requires additional PHP extensions.

  • Memcached: A high-performance, distributed memory object caching system.
  • Redis: An in-memory data structure store, used as a database, cache, and message broker.

For detailed installation guides, refer to:


6. Installing PHP Extensions for Memcached and Redis

To use Memcached and Redis with PHP, you need to install their respective PHP extensions for each PHP version you are using.

Installing PHP Memcached Extension

Step 1: Open EasyApache 4

Navigate to EasyApache 4 in WHM.

Step 2: Customize PHP Extensions
  • Click Customize next to your active profile.
  • Select PHP Extensions.
Step 3: Install Memcached Extension

For each PHP version (e.g., PHP 8.2, PHP 8.3), search for and enable:

  • php8.2-memcached or php8.3-memcached
Step 4: Provision the Changes

Click Review and then Provision to install the extension.

Installing PHP Redis Extension

Step 1: Open EasyApache 4

Again, go to EasyApache 4 in WHM.

Step 2: Customize PHP Extensions

Select PHP Extensions.

Step 3: Install Redis Extension

For each PHP version, search for and enable:

  • php8.2-redis or php8.3-redis
Step 4: Provision the Changes

Click Review and then Provision to install the extension.

Note on PECL Module Installer

If the extensions are not available in EasyApache 4, you can install them using the PECL module installer:

  1. Go to Module Installers in WHM.
  2. Click on Manage under PHP PECL.
  3. Select the PHP version.
  4. Install memcached or redis extensions.

7. Verifying Installed Extensions

To confirm the installation of the required PHP extensions, you can create a simple PHP info file.

Step 1: Create a PHP Info File

Run the following command to create a PHP file that outputs the currently installed extensions:

echo "<?php phpinfo();" | sudo tee /usr/local/apache/htdocs/info.php

Step 2: Access the PHP Info Page

Open a browser and navigate to http://your-server-ip/info.php. Scroll through the page and verify that the installed extensions, including Exif, Fileinfo, Imagick, PHP-Intl, Memcached, and Redis, are listed.

Step 3: Remove the PHP Info File

After verifying the installation, remove the PHP info file for security reasons:

sudo rm /usr/local/apache/htdocs/info.php

8. Common Issues and Troubleshooting

Issue 1: Extensions Not Appearing in PHP Info

Solution:

  • Ensure the extensions are installed and enabled via EasyApache 4 or PECL for the correct PHP version.
  • Restart Apache after provisioning or installing the extensions.

Issue 2: PECL Installation Fails

Solution:

  • Make sure php-pear is installed:
  sudo dnf install php-pear
  • Try reinstalling the PECL extension and ensure you’re using the correct PHP version.

Issue 3: Imagick or GD Not Working for Image Processing

Solution:

  • Ensure both Imagick and GD extensions are enabled for the PHP version you are using.
  • Check WordPress media settings to confirm the image library is properly configured.

Issue 4: PHP-Intl Not Working for Localization

Solution:

  • Ensure that the php-intl extension is enabled and active for the correct PHP version.
  • Verify that Apache was restarted after installation to apply the changes.

Issue 5: Memcached or Redis Not Working with PHP

Solution:

  • Confirm that the Memcached or Redis services are running.
  • Ensure the php-memcached or php-redis extensions are installed and enabled for your PHP version.
  • Check the configuration files for Memcached (/etc/sysconfig/memcached) and Redis (/etc/redis.conf) for any misconfigurations.

9. Conclusion

Installing and managing PHP extensions for WordPress via WHM/cPanel is crucial for optimal performance and compatibility, especially with PHP 8.2 and PHP 8.3 being the recommended versions as of September 2024. By using EasyApache 4, you can install necessary extensions like Exif, Fileinfo, Imagick, PHP-Intl, and more, per PHP version. Additionally, integrating caching solutions like Memcached and Redis can significantly enhance your site’s performance. Always verify the installation and troubleshoot any issues to ensure a smooth and secure WordPress experience.


Picture of admin

admin

Leave a Reply

Sign up for our Newsletter

Get the latest information on what is going on in the I.T. World.