- 在安装完mamp后启动服务,勾选 ☑️Make this version available on the command line
保存后,在命令行中输入php -v
,则已经将当前php环境添加到环境变量了
wait973@973 local % php -v
PHP 7.3.9 (cli) (built: Feb 17 2020 12:46:14) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
wait973@973 local %
- 在php版本的目录下 下载
git clone https://github.com/phpredis/phpredis.git
正克隆到 'phpredis'...
remote: Enumerating objects: 11051, done.
remote: Counting objects: 100% (230/230), done.
remote: Compressing objects: 100% (101/101), done.
remote: Total 11051 (delta 152), reused 180 (delta 129), pack-reused 10821
接收对象中: 100% (11051/11051), 7.86 MiB | 104.00 KiB/s, 完成.
处理 delta 中: 100% (7660/7660), 完成.
进入 phpredis cd phpredis
使用命令开始编译安装 :/Applications/MAMP/bin/php/php7.3.9/bin/phpize && ./configure && make && sudo make install
但是运行的结果会报错~
checking whether to enable lzf compression... no
checking use system liblzf... no
checking whether to enable Zstd compression... no
checking use system libsztd... yes
checking whether to enable lz4 compression... no
checking use system liblz4... no
checking for hash includes... configure: error: Cannot find php_hash.h
后来发现是php-config路径指向不对,重新修改路径:
/Applications/MAMP/bin/php/php7.3.9/bin/phpize && ./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.9/bin/php-config
这样就可以了
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
./configure: line 624: test: export: binary operator expected
./configure: line 624: test: export: binary operator expected
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-darwin20.3.0
checking host system type... x86_64-apple-darwin20.3.0
checking target system type... x86_64-apple-darwin20.3.0
checking for PHP prefix... /Applications/MAMP/bin/php/php7.3.9
checking for PHP includes... -I/Applications/MAMP/bin/php/php7.3.9/include/php -I/Applications/MAMP/bin/php/php7.3.9/include/php/main -I/Applications/MAMP/bin/php/php7.3.9/include/php/TSRM -I/Applications/MAMP/bin/php/php7.3.9/include/php/Zend -I/Applications/MAMP/bin/php/php7.3.9/include/php/ext -I/Applications/MAMP/bin/php/php7.3.9/include/php/ext/date/lib
checking for PHP extension directory... /Applications/MAMP/bin/php/php7.3.9/lib/php/extensions/no-debug-non-zts-20180731
checking for PHP installed headers prefix... /Applications/MAMP/bin/php/php7.3.9/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 json serializer support... yes
checking whether to enable igbinary serializer support... no
checking whether to enable msgpack serializer support... no
checking whether to enable lzf compression... no
checking use system liblzf... no
checking whether to enable Zstd compression... no
checking use system libsztd... yes
checking whether to enable lz4 compression... no
checking use system liblz4... no
checking for hash includes... /Applications/MAMP/bin/php/php7.3.9/include/php
checking for json includes... /Applications/MAMP/bin/php/php7.3.9/include/php
checking for redis json support... enabled
checking for redis igbinary support... disabled
checking for pkg-config... no
checking for git... yes
checking for ld used by cc... /Library/Developer/CommandLineTools/usr/bin/ld
checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
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... 786432
checking command to parse /usr/bin/nm -B 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 (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin20.3.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
完成后,进入/Applications/MAMP/bin/php/php7.3.9/conf
打开php.ini
添加:
[Redis]
extension=redis.so
- 至此安装Redis扩展已经成功了,修改了
php.ini
后重启一下php环境,输入php-m
搞定~