尝试从自制的PHP5.3连接到Redis

安装phpredis

brew install php53-redis
==> Downloading https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
######################################################################## 100.0%
==> PHP_AUTOCONF="/usr/local/opt/autoconf/bin/autoconf" PHP_AUTOHEADER="/usr/local/opt/autoconf/bin/autoheader" /usr/local/Cellar/php53/5.3.28/bin/phpize
==> ./configure --prefix=/usr/local/Cellar/php53-redis/2.2.4 --with-php-config=/usr/local/Cellar/php53/5.3.28/bin/php-config
==> make
==> Caveats
To finish installing redis for PHP 5.3:
  * /usr/local/etc/php/5.3/conf.d/ext-redis.ini was created,
    do not forget to remove it upon extension removal.
  * Validate installation via one of the following methods:
  *
  * Using PHP from a webserver:
  * - Restart your webserver.
  * - Write a PHP page that calls "phpinfo();"
  * - Load it in a browser and look for the info on the redis module.
  * - If you see it, you have been successful!
  *
  * Using PHP from the command line:
  * - Run "php -i" (command-line "phpinfo()")
  * - Look for the info on the redis module.
  * - If you see it, you have been successful!
==> Summary

启动交互式 Shell

php -a

确认

$redis = new Redis();
$redis->connect('127.0.0.1');
$redis->set('hello', 'world');
var_dump($redis->get('hello'));
string(5) "world"

请结束交互式命令行界面。

quit
广告
将在 10 秒后关闭
bannerAds