MAC下PHP拓展Redis插件

下载安装phpredis拓展

github下载phpredis拓展项目:

git clone https://github.com/phpredis/phpredis.git

或下载稳定版本:

http://pecl.php.net/package/redis

解压(稳定版):

bogon:~ Brave$ tar xzf redis-3.1.4.tgz

MAC下PHP拓展Redis插件_第1张图片

cd 到redis-3.1.4目录下

bogon:~ Brave$ cd redis-3.1.4

执行sudo /Applications/XAMPP/xamppfiles/bin/phpize

bogon:redis-3.1.4 Brave$ sudo /Applications/XAMPP/xamppfiles/bin/phpize
Password:
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

安装遇到问题:$PHP_AUTOCONF environment variable. Then, rerun this script.

Error: Could not link:
/usr/local/share/doc/homebrew

Please delete these paths and run `brew update`.
/usr/local/Homebrew/Library/Homebrew/brew.rb:12:in `
': Homebrew must be run under Ruby 2.3! You're running 2.0.0. (RuntimeError)

删除/usr/local/share/doc/homebrew,重新更新brew

bogon:~ Brave$ brew update
Updated 1 tap (homebrew/core).
==> Updated Formulae
abcm2ps         bacula-fd       gitlab-runner   lldpd           tippecanoe
armadillo       bmake           kompose         remake          zimg

安装autoconf,提示缺少xcode-select

bogon:~ Brave$ brew install autoconf
Error: Xcode alone is not sufficient on Yosemite.
Install the Command Line Tools:
  xcode-select --install

安装xcode-select –install,弹出Xcode,等待安装完成
再次安装autoconf:

bogon:~ Brave$ brew install autoconf
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
clhep           firebase-cli    fonttools       ibex            iso-codes

==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.yosemite.bott
######################################################################## 100.0%
==> Pouring autoconf-2.69.yosemite.bottle.4.tar.gz

再次sudo /Applications/XAMPP/xamppfiles/bin/phpize

bogon:~ Brave$ cd redis-3.1.4
bogon:redis-3.1.4 Brave$ sudo /Applications/XAMPP/xamppfiles/bin/phpize
Password:
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226

运行./configure -with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config

bogon:redis-3.1.4 Brave$ ./configure -with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin14.5.0
checking host system type... x86_64-apple-darwin14.5.0
checking target system type... x86_64-apple-darwin14.5.0
checking for PHP prefix... /Applications/XAMPP/xamppfiles
checking for PHP includes... -I/Applications/XAMPP/xamppfiles/include/php -I/Applications/XAMPP/xamppfiles/include/php/main -I/Applications/XAMPP/xamppfiles/include/php/TSRM -I/Applications/XAMPP/xamppfiles/include/php/Zend -I/Applications/XAMPP/xamppfiles/include/php/ext -I/Applications/XAMPP/xamppfiles/include/php/ext/date/lib
checking for PHP extension directory... /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226
checking for PHP installed headers prefix... /Applications/XAMPP/xamppfiles/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable redis support... yes, shared
checking whether to enable sessions... yes
checking whether to enable igbinary serializer support... no
checking for redis igbinary support... disabled
checking for ld used by cc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking if cc supports -fno-rtti -fno-exceptions... yes
checking for cc option to produce PIC... -fno-common
checking if cc PIC flag -fno-common works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin14.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h

编译make & make install

可能会出现错误:

make: *** [redis.la] Error 1
bogon:redis-3.1.4 Brave$ libtool: link: `redis_session.lo' is not a valid libtool object

make clean一下

bogon:redis-3.1.4 Brave$ make clean
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f 
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la       modules/* libs/*
[1]+  Exit 2                  make

重新编译sudo make install

/bin/sh /Users/Brave/redis-3.1.4/libtool --mode=install cp ./redis.la /Users/Brave/redis-3.1.4/modules
cp ./.libs/redis.so /Users/Brave/redis-3.1.4/modules/redis.so
cp ./.libs/redis.lai /Users/Brave/redis-3.1.4/modules/redis.la
----------------------------------------------------------------------
Libraries have been installed in:
   /Users/Brave/redis-3.1.4/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:     /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226/

此时/Users/Brave/redis-3.1.4/modules下的redis.so已复制到
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226/中

配置Php.ini

进入phpinfo页面找到Xampp下的php.ini位置

phpini

打开php.ini添加redis拓展配置

extension="redis.so"

重新启动Xampp,访问phpinfo查看redis插件

phpredis

phpinfo页面出现redis插件信息显示,说明redis插件安装成功

你可能感兴趣的:(PHP)