Getting a 'Please make sure the PHP Redis extension is installed and enabled.' error despite the extension being loaded
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Decoding the Paradox: Why PHP Redis Extension Errors Persist Despite Successful Installation
As senior developers working with complex PHP environments, we often encounter situations where the system reports contradictory information. You have successfully installed an extension, verified its presence in php.ini, and confirmed it loads perfectly in a command-line context, yet your application throws a runtime error stating that the required module is missing or disabled.
This post dives deep into the perplexing scenario of receiving the dreaded "Please make sure the PHP Redis extension is installed and enabled." error within a Laravel application, even when extension_loaded('redis') returns true via tools like phpinfo() or Tinker. We will uncover the subtle environmental mismatches that cause this paradox and provide the definitive steps to resolve it.
The Paradox Explained: CLI vs. Web Server Environment
The core of this issue lies in the difference between how PHP executes code in different contexts—specifically, the Command Line Interface (CLI) versus a web server environment (like FPM or Apache/Nginx handling requests).
When you run phpinfo() or use Tinker, you are interacting with the PHP interpreter directly via the command line. This environment loads the configuration and extensions based on the standard CLI setup. In your case, this confirms that the redis.so file is correctly loaded for the CLI session.
However, when a web request hits your Laravel application, it runs under a different process context managed by your web server's PHP handler (e.g., PHP-FPM). This web server environment might be loading a different set of configuration files or extension modules than the one you checked in your local terminal session.
The error originates deep within frameworks like Laravel, specifically when checking extension_loaded('redis') inside components like PhpRedisConnector. If this check fails in the context of the request, it signals that the module is inaccessible to the web server process, even if it is present on the system.
Diagnosing the Root Cause: Environment Mismatch
The most common culprits for this discrepancy are related to how PHP modules are compiled or how the web server environment is initiated.
1. Inconsistent PHP Installations
If you installed Redis via pecl install redis, the module was placed in a specific location (/usr/local/Cellar/php/7.3.12/pecl/...). If your web server (e.g., PHP-FPM) is configured to use an alternative PHP binary or a custom compilation path, it might be loading a different version of the extension or failing to recognize the module entirely at startup.
2. FPM Configuration Overrides
The configuration files loaded by PHP-FPM are separate from the standard php.ini used by the CLI. You need to ensure that the specific PHP process handling your web requests is properly linked to the compiled extension library.
Practical Solutions and Best Practices
To resolve this conflict, we must force consistency between the environment where you test and the environment where your application runs.
Step 1: Verify Web Server Configuration
Examine the configuration files used by your web server (e.g., /etc/php/7.3/fpm/php.ini or equivalent). Ensure that the extension_dir settings are correctly pointing to where PHP looks for extensions, and verify that no specific exclusion rules are inadvertently blocking the loading of Redis.
Step 2: Recompile or Reinstall (The Deep Fix)
If the configuration seems correct, the issue often resides in the extension linking itself. A robust solution is to re-run the installation process, ensuring it correctly links against your specific PHP installation used by the web server. If you are using a tool like Docker or a custom build system, ensure that the build process explicitly handles the compilation for all target environments.
Step 3: Rely on Laravel’s Abstraction
As good practice, always rely on the framework's abstractions rather than raw extension checks when dealing with third-party packages. Frameworks like Laravel are designed to handle potential missing dependencies gracefully. When you see framework errors related to Redis, focus on ensuring the connection parameters and configuration (like those detailed in guides on managing services, similar to those found on laravelcompany.com).
Conclusion
The situation where extension_loaded('redis') is true in Tinker but an application throws a missing extension error is a classic symptom of an environmental disconnect between the CLI execution context and the web server execution context. By moving beyond simple checks and meticulously auditing your PHP-FPM configuration, ensuring correct module linking, and focusing on environment consistency, you can eliminate this frustrating paradox and ensure a stable deployment for your application.