技术&日志

mac-redis

/usr/local/redis-5.0.5

默认-php7.1.23

配置文件: vi /private/etc/php.ini (cp php.ini.default php.ini)
扩展文件: /usr/lib/php/extensions/no-debug-non-zts-20160303

brew-php5.6

配置文件: /usr/local/etc/php/5.6/php.ini
扩展文件: /usr/local/Cellar/php@5.6/5.6.40/pecl/20131226/

下载php扩展源码: php-redis-4.3.0.tgz

解压并安装(错误看错误处理):

tar -xzvf redis-4.3.0.tgz

phpize

./configure 

sudo make && sudo make install

复制编译好的redis.so到php扩展文件夹中 sudo cp /Users/jw/Downloads/redis-4.3.0/modules/redis.so /usr/lib/php/extensions/no-debug-non-zts-20160303/

错误处理

执行phpize出现错误的话

错误1处理

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.

xcode-select --install 执行命令安装

错误2处理

cd /Library/Developer/CommandLineTools/Packages/
// 不同的mac系统, 可能名字不一样
open macOS_SDK_headers_for_macOS_10.14.pkg

错误3处理

访问127.0.0.1:8080正常 访问80出现拒绝访问(ERR_CONNECTION_REFUSED) 执行命令sudo nginx (原因php-fpm使用sudo启动 nginx普通启动)

相关资料

Mac环境下安装Redis
mac 中安装redis扩展过程
mac-PHP5.6 redis扩展

发表评论