$ wget 'http://php.net/distributions/php-7.4.4.tar.gz'
$ tar xf php-7.4.4.tar.gz
$ cd php-7.4.4
$ ./configure --prefix=/path/to/php --enable-embed
$ make
如果遇到bug-78773, fatal error: 'libxml/parser.h' file not found
$ brew install libxml2
$ ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2/libxml /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml
$ git clone https://github.com/rryqszq4/ngx_php7.git
$ sh ngx_php7/utils/php-bug-66673.sh /path/to/php
$ cd php-7.4.4
$ make
$ sh ngx_php7/utils/php-bug-66673.sh /path/to/php
$ cd php-7.4.4
$ make
注释掉libs/libphp$(PHP_MAJOR_VERSION).bundle...行 添加libphp7.dylib行
#libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
# $(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so
libphp7.dylib: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) -fPIC -dynamiclib $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
如果报错clang: error: unknown argument: '-module', 修改EXTRA_LDFLAGS...行如下:
#EXTRA_LDFLAGS = -avoid-version -module -L/usr/local/opt/libiconv/lib
EXTRA_LDFLAGS = -avoid-version -L/usr/local/opt/libiconv/lib
编译libphp7.dylib, 然后拷贝到php安装目录lib中
$ make libphp7.dylib
$ cp libphp7.dylib /path/to/php/lib
$ wget 'http://nginx.org/download/nginx-1.12.2.tar.gz'
$ tar -zxvf nginx-1.12.2.tar.gz
$ cd nginx-1.12.2
$ export PHP_CONFIG=/path/to/php/bin/php-config
$ export PHP_BIN=/path/to/php/bin
$ export PHP_INC=/path/to/php/include/php
$ export PHP_LIB=/path/to/php/lib
$ ./configure --user=www --group=www \
$ --prefix=/path/to/nginx \
$ --with-ld-opt="-Wl,-rpath,$PHP_LIB" \
$ --add-module=/path/to/ngx_php7/third_party/ngx_devel_kit \
$ --add-module=/path/to/ngx_php7
$ make && make install
关于php bug-66673: https://bugs.php.net/bug.php?id=66673
关于php bug-78773: https://bugs.php.net/bug.php?id=78773