1、下载predis。
https://github.com/nrk/phpiredis
https://packagist.org/packages/predis/predis
2、测试文件redis.php。
<?php require_once('./predis-1.1.1/autoload.php'); $host = "127.0.0.1"; $port = 6379; $user = ""; $pwd = ""; //$client = new Predis\Client(['host'=>$host, 'port'=>$port, 'database'=>$user, 'password'=>$pwd]); $client = new Predis\Client(); $client->set('name', 'jzh'); $value = $client->get('name'); echo $value; ?>