您的位置:首页 > 数据库 > Redis

mac 中安装redis 以及 安装php-redis扩展过程详细记录

2017-01-19 23:24 751 查看
1. 通过homebrew 安装 redis

sodu  brew install redis


2. 安装后执行开启redis,采用默认配置, 默认配置只有本地(127.0.0.1)可以访问。需要远程访问的话修改配置,注释bind 127.0.0.1即可。当然还要设置防火墙。

sudo redis-server


3.查看redis 是否正常工作

sudo redis-cli


redis 安装工作就结束了。

下面是安装php-redis扩展。默认php 是不带有连接操作redis的库的所以需要安装php-redis扩展库.

wget -c https://nodeload.github.com/nicolasff/phpredis/zip/master 
得到文件 master,解压并安装:

tar -zxvf master

cd phpredis-master

sudo phpize

./configure

sudo make && make install


如果顺利到这一步系统就会给出redis.so文件的路径。

但是 mac系统下 phpize 往往会有问题。报错如下:

grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.


解决办法:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ /usr/include


但是由于mac 有Rootless功能,该功能使得即使是root 用户也无法修改一些系统目录,系统默认将会锁定
/system
/sbin
/usr
这三个目录使其无法修改。

可以暂时关闭Rootless功能,这里暂不讲解。

也可以使用以下方法 执行命令: 它会配置好Unix开发环境

xcode-select --install


执行这个命令后就不用再执行ln 这条命令了

再次执行

sudo  phpize


发现还是报错错误为:

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.


解决方法是:

brew install autoconf
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: