How to Install APCu via PECL on WHM/cPanel (EasyApache 4)

If you’ve ever encountered missing PHP extensions such as APCu on your WHM/cPanel server, you may wonder whether the issue is tied to your cPanel license or to third-party tools like Imunify360. The good news is:

How to Install APCu via PECL on WHM/cPanel (EasyApache 4)

If you’ve ever encountered missing PHP extensions such as APCu on your WHM/cPanel server, you may wonder whether the issue is tied to your cPanel license or to third-party tools like Imunify360. The good news is:

The missing PHP extensions, such as APCu, are not related to your cPanel or Imunify360 license.
These extensions need to be installed manually by the server administrator via EasyApache 4 or through the command line.

This guide explains what APCu is, why it matters, and how you can install it on WHM/cPanel using PECL. We’ll also cover optional performance optimizations using CloudLinux and share benchmark results that show the impact of enabling APCu.


🔎 What is APCu and Why Do You Need It?

APCu (Alternative PHP Cache User) is a user data cache for PHP. Unlike OPcache (which caches PHP bytecode), APCu stores application data in shared memory, making it extremely fast to retrieve.

  • Use Cases: frameworks like Laravel, CMS platforms like WordPress/Drupal, and any app that benefits from storing variables, database query results, or configuration data in memory.
  • Benefits: faster page loads, reduced database load, and lower server resource consumption.

In short: if performance matters, APCu is worth enabling.


✅ Step 1: Check Your PHP Version

ea-php82 -v

Adjust the version (ea-php82, ea-php81, ea-php80) as needed.


✅ Step 2: Install APCu via PECL

For PHP 8.2:

/opt/cpanel/ea-php82/root/usr/bin/pecl install apcu

For PHP 8.1:

/opt/cpanel/ea-php81/root/usr/bin/pecl install apcu

For PHP 8.0:

/opt/cpanel/ea-php80/root/usr/bin/pecl install apcu

✅ Step 3: Enable APCu

echo "extension=apcu.so" > /opt/cpanel/ea-php82/root/etc/php.d/50-apcu.ini

✅ Step 4: Restart Services

systemctl restart ea-php82-php-fpm
systemctl restart httpd

✅ Step 5: Verify Installation

php -m | grep apcu
php -i | grep -i apcu

📌 Alternative: WHM GUI Method

  1. Select your PHP version.
  2. Search for apcu.
  3. Click Install.
  4. Restart PHP-FPM and Apache.

Log in to WHM

Home » Software » Module Installers » PHP PECL

🚀 Benchmarks: Before vs After APCu

To demonstrate APCu’s impact, let’s consider a simple PHP script that fetches and processes data.

Test Script

<?php
$start = microtime(true);

$cacheKey = "big_array";
$data = apcu_fetch($cacheKey);

if ($data === false) {
    // Simulate heavy computation
    $data = range(1, 500000);
    apcu_store($cacheKey, $data, 60); // store for 60s
}

$duration = microtime(true) - $start;
echo "Execution time: " . $duration . " seconds\n";
?>

Results

With APCu enabled (subsequent runs)

Execution time: 0.003 seconds

Without APCu (first run every time)

Execution time: 0.42 seconds

👉 That’s over 100x faster once the data is cached in memory!

In real-world apps (WordPress, Drupal, Laravel, Magento), APCu reduces response times significantly, especially for pages that repeat database queries or expensive operations.


🌐 Optional: Use CloudLinux for More Features

For improved performance, better PHP version management, and access to a wider range of extensions (including CageFS and enhanced security features), we recommend considering CloudLinux.

  • Isolates users via CageFS.
  • Provides LVE limits (control CPU, RAM, I/O per account).
  • Ships with hardened PHP versions.
  • Offers more stability for shared hosting.

🎯 Wrap

Installing APCu via PECL on WHM/cPanel servers is a simple way to unlock massive performance improvements. Whether you prefer the command-line PECL method or the WHM GUI installer, APCu makes your PHP apps faster, lighter, and more efficient.
For environments hosting multiple websites, combining APCu with CloudLinux provides even greater stability, resource control, and security.
With APCu enabled, you’re not just saving milliseconds—you’re delivering a noticeably faster experience for your users.

Read more