Home >Backend Development >PHP Tutorial >php-redis extension installation (phpredis)
This article introduces the content of php-redis extension installation (phpredis), which has certain reference value. Now I share it with everyone. Friends in need can refer to it.
# wget http://pecl.php.net/get/redis-3.1.6.tgz # mv redis-3.1.6.tgz php-redis-3.1.6.tgz # tar -zxvf php-redis-3.1.6.tgz # mv redis-3.1.6 php-redis-3.1.6 # cd php-redis-3.1.6 # /usr/local/php/bin/phpize # ./configure --with-php-config=/usr/local/php/bin/php-config # make && make install
Modify the php.ini file
Add a line:
[redis] extension = redis.so
Restart php-fpm: kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`
##【php test 】
##//实例化redis
$redis = new Redis();
//连接
$redis->connect('127.0.0.1', 6379);
//检测是否连接成功
echo "Server is running: " . $redis->ping();
// 输出结果 Server is running: +PONG
Related recommendations:
The above is the detailed content of php-redis extension installation (phpredis). For more information, please follow other related articles on the PHP Chinese website!