0

env:

  • CentOS 6.5
  • php5.5.3 / php-fpm5.5.3
  • nginx 1.0.15
  • php-redis 2.2.8

also added extension_dir and extension settings in php.ini

then restart the service of php-fpm & nginx

and i have confirmed the redis has been enabled/loaded in phpinfo()

step:

i'm trying to run the php script like this

<?php
$redis = new Redis();
?>

got error:

PHP Fatal error:  Call to undefined function  new Redis() in /home/html/test1.php on line 2

but when i'm trying to run the same command in php Interactive shell mode, it works well.

why?

update:

i have test a script like this:

print_r(get_loaded_extensions());

then i got already loaded extension redis

if(class_exists('Redis')){
 echo 'Redis loaded';
 $redis = new Redis();
 }else{
 echo 'not function Redis';
 }

it shows class Redis exist but still get error

[root@i1 html]# php -f test1.php
 Redis loadedPHP Fatal error: Call to undefined function  new Redis() in /home/html/test1.php on line 16

add dl("redis.so"); and the output:

PHP Warning:  Module 'redis' already loaded in Unknown on line 0
Redis loadedPHP Fatal error:  Call to undefined function  new Redis() in /home/html/test1.php on line 18
Community
  • 1
  • 1
Sylar Li
  • 1
  • 2

1 Answers1

0

finally, i cant config to use the phpredis plugin.

predis is the better choice in this case.

Sylar Li
  • 1
  • 2