Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deshiloh's avatar

PHP Redis extension on MAC OSX

Hi !

Having trouble with php redis extension installation.

i searched on internet but every fix i founded didn't work.

i tried sudo pecl install redis but i had :

sudo pecl install redis
PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/local/lib/php/pecl/20190902/redis.so (dlopen(/usr/local/lib/php/pecl/20190902/redis.so, 9): image not found), /usr/local/lib/php/pecl/20190902/redis.so.so (dlopen(/usr/local/lib/php/pecl/20190902/redis.so.so, 9): image not found)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/local/lib/php/pecl/20190902/redis.so (dlopen(/usr/local/lib/php/pecl/20190902/redis.so, 9): image not found), /usr/local/lib/php/pecl/20190902/redis.so.so (dlopen(/usr/local/lib/php/pecl/20190902/redis.so.so, 9): image not found)) in Unknown on line 0
downloading redis-5.1.1.tgz ...
Starting to download redis-5.1.1.tgz (245,205 bytes)
...................................................done: 245,205 bytes
25 source files, building
running: phpize
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
enable igbinary serializer support? [no] : yes

Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in Builder.php on line 407
PHP Warning:  Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /usr/local/Cellar/php/7.4.2/share/php/pear/PEAR/Builder.php on line 407

Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /usr/local/Cellar/php/7.4.2/share/php/pear/PEAR/Builder.php on line 407
enable lzf compression support? [no] : yes

Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in Builder.php on line 407
PHP Warning:  Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /usr/local/Cellar/php/7.4.2/share/php/pear/PEAR/Builder.php on line 407

Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /usr/local/Cellar/php/7.4.2/share/php/pear/PEAR/Builder.php on line 407
enable zstd compression support? [no] : yes

Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in Builder.php on line 407
PHP Warning:  Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /usr/local/Cellar/php/7.4.2/share/php/pear/PEAR/Builder.php on line 407

Warning: Use of undefined constant name - assumed 'name' (this will throw an Error in a future version of PHP) in /usr/local/Cellar/php/7.4.2/share/php/pear/PEAR/Builder.php on line 407
building in /private/tmp/pear/temp/pear-build-rootLGGBo1/redis-5.1.1
running: /private/tmp/pear/temp/redis/configure --with-php-config=/usr/local/opt/php/bin/php-config --enable-redis-igbinary=yes --enable-redis-lzf=yes --enable-redis-zstd=yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin19.2.0
checking host system type... x86_64-apple-darwin19.2.0
checking target system type... x86_64-apple-darwin19.2.0
checking for PHP prefix... /usr/local/Cellar/php/7.4.2
checking for PHP includes... -I/usr/local/Cellar/php/7.4.2/include/php -I/usr/local/Cellar/php/7.4.2/include/php/main -I/usr/local/Cellar/php/7.4.2/include/php/TSRM -I/usr/local/Cellar/php/7.4.2/include/php/Zend -I/usr/local/Cellar/php/7.4.2/include/php/ext -I/usr/local/Cellar/php/7.4.2/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/Cellar/php/7.4.2/pecl/20190902
checking for PHP installed headers prefix... /usr/local/Cellar/php/7.4.2/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable redis support... yes, shared
checking whether to disable sessions... yes
checking whether to disable json serializer support... yes
checking whether to enable igbinary serializer support... yes
checking whether to enable msgpack serializer support... no
checking whether to enable lzf compression... yes
checking use system liblzf... no
checking whether to enable Zstd compression... yes
checking use system libsztd... yes
checking for json includes... /usr/local/Cellar/php/7.4.2/include/php
checking for redis json support... enabled
checking for igbinary includes... configure: error: Cannot find igbinary.h
ERROR: `/private/tmp/pear/temp/redis/configure --with-php-config=/usr/local/opt/php/bin/php-config --enable-redis-igbinary=yes --enable-redis-lzf=yes --enable-redis-zstd=yes' failed

I also tried before adding extension=redis.so in my php.ini and restart php with brew services restart php :

git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install

Not works as well... still have the error :

Please make sure the PHP Redis extension is installed and enabled.
0 likes
17 replies
deshiloh's avatar

@bugsysha I tried vessel but I have a problem with storage link, i also use devil box, both work with docker, both are also pretty slow on mac os x. So i would like to try with valet.

I take any more advices for a good dev env.

bugsysha's avatar

both are also pretty slow on mac os x

Same for me, but I'm willing to accept that tradeoff to keep my host machine as clean as possible.

I tried vessel but I have a problem with storage link

I've never tried vessel but I'm using docker-compose and everything is working for me. You can even build simple container which just runs everything within that single container to make things easy and just add Redis and avoid any macOS Redis installation issues.

deshiloh's avatar

@bugsysha Do you build your own docker-compose file ? or are you using something magic like devilbox ?

bugsysha's avatar

I've built my own. And it is super simple to avoid any complication since I do not know much about docker. Any complex builds are done by others and I just use them.

bugsysha's avatar

Sure.

I for simplest use cases

For PHP I have php.yml file with following:

version: '3'

services:
    phpcontainer:
        container_name: ${APP_NAME}_laravel
        entrypoint: 'php artisan serve --host 0.0.0.0'
        image: php:7.4-fpm
        ports:
            - 8000:8000
        volumes:
            - ./:/var/www/html:cached

For Node/NPM I have node.yml file with following

version: '3'

services:
    nodecontainer:
        container_name: ${APP_NAME}_node
        working_dir: /home/node/app
        image: node:12-alpine
        volumes:
          - ./:/home/node/app:cached
        command: sh -c "npm install --quiet && npm run watch"

Node containers do not run in background. They just execute the code and exit.

Some uses:

// PHP
docker-compose -f php.yml up -d // start container
docker-compose -f php.yml stop // stop container without deleting
docker-compose -f php.yml exec phpcontainer /bin/bash // this will "ssh" you to that container so you can install redis for example
// examples below allow you to run commands in container without "ssh"-ing to it
docker-compose -f php.yml exec phpcontainer php artisan migrate

// Node
docker-compose -f node.yml exec nodecontainer /bin/bash // this will "ssh" you to that container
// examples below allow you to run commands in container without "ssh"-ing to it
docker-compose -f node.yml exec nodecontainer npm install
docker-compose -f node.yml exec nodecontainer npm run dev
docker-compose -f node.yml exec nodecontainer npm run prod
docker-compose -f node.yml exec nodecontainer npm run watch
docker-compose -f node.yml exec nodecontainer npx tailwind init
docker-compose -f node.yml exec nodecontainer npx tailwind build styles.css -o output.css

Also I have those php.yml and node.yml files excluded from Git via global gitignore.

deshiloh's avatar

Thank you ! I'll take a look of that !

bugsysha's avatar

Just note that those use cases contain comments at the end of the line. For example

docker-compose -f php.yml up -d // start container

This is command

docker-compose -f php.yml up -d

This is comment

// start container

Formatting was not clear.

fylzero's avatar
fylzero
Best Answer
Level 67

@deshiloh I really can't think of any good reason you would necessarily need to run Redis on your machine. You can use a different cache driver and run jobs in sync locally. You really don't need scale protection locally is my point. Using this to "test" is probably useless as you'd just be testing the framework of something you should expect to be working, if that makes sense.

1 like
fylzero's avatar

@deshiloh I was kind of feeling like that is the real answer. It isn't easy to do, because most people don't do it, because it doesn't really need to be done.

deshiloh's avatar

I think i did it on local env to be sure all worked with redis, i just started with laravel so using redis is kind of something new for me ^^ that's my excuse :p

fylzero's avatar

@deshiloh Yeah, I get it. I just think of it like using Mailtrap or anything else. You don't need to build an SMTP server to know email works from Laravel. Right? Same concept. Redis and workers do their job. Amazon SQS just works, etc. No need to test it locally, especially considering that locally you probably won't even be using the same flavor of Redis the service you will end up using will have.

Mwangaben's avatar

For local development if you want to use php with Redis you can install predis as composer require predis/predis on the project directory. then on .env file set REDIS_CLIENT=predis as this is set to phpredis on the config/database.php by default

1 like

Please or to participate in this conversation.