How to Install phpredis on CentOS 8 / RHEL 8

How to Install phpredis on CentOS 8 / RHEL 8

To install phpredis on CentOS 8 or RHEL 8, you can use the following steps:

  1. Install the required packages:
ref‮ re‬to:lautturi.com
sudo dnf install -y gcc make php-devel

This will install the gcc, make, and php-devel packages, which are required to build the phpredis extension.

  1. Install the phpredis extension using pecl:
sudo pecl install redis

This will download and build the phpredis extension and install it on your system.

  1. Enable the phpredis extension in PHP:
echo "extension=redis.so" | sudo tee -a /etc/php.d/redis.ini

This will create a configuration file for the phpredis extension and enable it in PHP.

  1. Restart the PHP-FPM service:
sudo systemctl restart php-fpm

This will apply the changes and make the phpredis extension available to your PHP scripts.

  1. Test the installation:

Create a PHP file in the document root of your web server with the following code:

<?php
if (extension_loaded('redis')) {
    echo "phpredis is installed.";
} else {
    echo "phpredis is not installed.";
}
?>

Save the file and access it from a web browser. If the phpredis extension is installed, you should see the message "phpredis is installed." If you still see the error message, you may need to check your PHP configuration or seek help from the PHP community.

Created Time:2017-10-28 21:38:57  Author:lautturi