Databases 3 min read

How to Install and Configure phpRedis Extension for PHP 7.4 on Linux

This guide walks you through downloading, extracting, configuring, compiling, and installing the phpRedis C extension for PHP 7.4, shows how to enable it in php.ini, and provides commands to verify that the Redis extension is loaded correctly.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
How to Install and Configure phpRedis Extension for PHP 7.4 on Linux

Introduction

phpredis is a PHP extension written in C that provides an API to communicate with a Redis key‑value store. It is released under the PHP License 3.01 and was originally developed by Owlient between November 2009 and March 2011. The source code is hosted at https://github.com/phpredis/phpredis.

Installation

Download

$ wget http://pecl.php.net/get/redis-5.3.2.tgz
# (example output showing download progress)

Extract

$ tar -zxvf redis-5.3.2.tgz
# extracts package.xml, liblzf/LICENSE, etc.

Generate configure script

$ /usr/local/php-7.4/bin/phpize
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902

Configure

Locate the php-config binary and point the configure script to it:

$ sudo find / -name php-config
/usr/local/php-7.4/bin/php-config
$ ./configure --with-php-config=/usr/local/php-7.4/bin/php-config

Compile

$ make -j4

Install

$ sudo make install
Installing shared extensions: /usr/local/php-7.4/lib/php/extensions/no-debug-non-zts-20190902/

Enable the extension

Add the following line to /usr/local/php-7.4/etc/php.ini:

extension=redis.so

Verify installation

From the command line:

$ php -m | grep redis
redis

Or by calling phpinfo() in a script and checking that the Redis section appears.

phpinfo output showing redis extension
phpinfo output showing redis extension
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backendphpredis
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.