I can't connect to redis using php
P粉465287592
P粉465287592 2023-09-01 15:37:59
0
2
529

I cannot connect to redis using php. I set up an environment with docker and tried to connect redis from php using php and redis containers, but it failed. I get the following error.

PHP Warning: PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/ usr/lib/php/20190902/redis.so: undefined symbol: php_json_decode_ex), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP Notice: session_start(): Redis not available while creating session_id in /var/www/html/index.php on line 2 PHP Warning: session_start(): Failed to read session data: redis (path: tcp://localhost:6379) in /var/www/html/index.php on line 2 string(0) "" save_handler=redis save_path=tcp://localhost:6379 session_id=

This is the php file that is executed in response to the error.

Part of the php.ini file.

[Session] ; Handler used to store/retrieve data. ; http://php.net/session.save-handler session.save_handler = redis session.save_path = "tcp://localhost:6379" ;verifying redis extension module extension=redis.so ; default redis timeout redis.timeout = 5

If I'm missing any information needed to resolve this issue, please let me know. Thank you in advance.

Attachment: I type ping and it returns pong. I can connect to redis from the php container using redis-cli. In addition, here is the path to redis.so. ~/usr/lib/php/20190902/redis.so Path to php.ini (the server used is apache2). ~/etc/php/7.4/apache2/php.ini

P粉465287592
P粉465287592

reply all (2)
P粉116631591
  1. Check if radish is working as a teamredis-cli pingAnswerpingpong

  2. Make sure your PHP configuration contains the correct settings for the Redis extension. Check whether thephp.inifile specifies the correct path toredis.soand other necessary configurations.

    P粉920199761

    I have adjusted the Php.ini file as follows.
    before fixing

    session.save_path = "tcp://localhost:6379"

    adjusted

    session.save_path = "tcp://redis:6379"

    Thanks.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!