$ wget https://github.com/phpredis/phpredis/archive/3.1.4.tar.gz
$ tar zxvf 3.1.4.tar.gz # 解壓
$ cd phpredis-3.1.4 # 進入 phpredis 目錄
$ /usr/local/php/bin/phpize # php安裝后的路徑
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make && make install
修改php.ini文件喷市,增加以下兩行
extension_dir = "/home/soft/php/lib/php/extensions/no-debug-non-zts-20190902"
extension=redis.so
$ redis-server /redis/etc/redis.conf? //啟動redis-server
<?php
? ? //連接本地的 Redis 服務??
?$redis = new Redis();?
$redis->connect('127.0.0.1', 6379);?
echo "Connection to server successfully";? ? ? ? //查看服務是否運行??
?echo "Server is running: " . $redis->ping();
?>
執(zhí)行腳本,輸出結果為:
Connection to server sucessfully
Server is running: PONG