下载 PHP7.1.0,并编译安装
$ wget https://baitexiaoyuan.oss-cn-zhangjiakou.aliyuncs.com/updatecrm/php/20230830/php-7.1.0.tar.gz
$ tar -zxvf php-7.1.0.tar.gz
$ cd php-7.1.0
$ ./configure --prefix=/Users/null/work/php/php-7.1.0/output --enable-fpm
$ make && make install
报错1
configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>
解决办法:安装 libiconv,增加编译参数 --with-iconv=/usr/local/opt/libiconv/
$ brew install libiconv
$ ./configure --prefix=/Users/null/work/php/php-7.1.0/output --enable-fpm --with-iconv=/usr/local/opt/libiconv/
报错2
/Users/null/work/php/php-7.1.0/main/reentrancy.c:139:23: error: too few arguments to function call, expected 3, have 2
readdir_r(dirp, entry);
~~~~~~~~~ ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/dirent.h:110:5: note: 'readdir_r' declared here
int readdir_r(DIR *, struct dirent *, struct dirent **) __DARWIN_INODE64(readdir_r);
^
1 error generated.
make: *** [main/reentrancy.lo] Error 1
解决办法:修改php源码 php-7.1.0/main/reentrancy.c
readdir_r(dirp, entry); // 139 行
改成
readdir_r(dirp, entry, &entry);
报错3
Undefined symbols for architecture x86_64:
"_libiconv", referenced from:
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_appendl in iconv.o
_php_iconv_stream_filter_append_bucket in iconv.o
...
"_libiconv_close", referenced from:
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_decode in iconv.o
_php_iconv_stream_filter_factory_create in iconv.o
...
"_libiconv_open", referenced from:
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_decode in iconv.o
_php_iconv_stream_filter_factory_create in iconv.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sapi/cli/php] Error 1
解决办法:修改 Makefile,-liconv -liconv 改成 -liconv /usr/local/opt/libiconv/lib/libiconv.dylib
# -liconv -liconv 改成 -liconv /usr/local/opt/libiconv/lib/libiconv.dylib
EXTRA_LIBS = -lresolv -liconv -liconv ... # 改之前
EXTRA_LIBS = -lresolv -liconv /usr/local/opt/libiconv/lib/libiconv.dylib ... # 改之后
报错4
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
directorytreeiterator.inc
clicommand.inc
directorygraphiterator.inc
invertedregexiterator.inc
pharcommand.inc
make: *** [ext/phar/phar.phar] Segmentation fault: 11
解决办法:编译参数增加 --without-pear --disable-phar
$ ./configure --without-pear --disable-phar --with-iconv=/usr/local/opt/libiconv/ --prefix=/Users/null/work/php/php-7.1.0/output --enable-fpm
$ vim Makefile // 修改 Makefile,-liconv -liconv 改成 -liconv /usr/local/opt/libiconv/lib/libiconv.dylib
$ make clean
$ make && make install
终于,编译安装成功了
Build complete.
Don't forget to run 'make test'.Installing shared extensions: /Users/null/work/php/php-7.1.0/output/lib/php/extensions/no-debug-non-zts-20160303/
Installing PHP CLI binary: /Users/null/work/php/php-7.1.0/output/bin/
Installing PHP CLI man page: /Users/null/work/php/php-7.1.0/output/php/man/man1/
Installing PHP FPM binary: /Users/null/work/php/php-7.1.0/output/sbin/
Installing PHP FPM config: /Users/null/work/php/php-7.1.0/output/etc/
Installing PHP FPM man page: /Users/null/work/php/php-7.1.0/output/php/man/man8/
Installing PHP FPM status page: /Users/null/work/php/php-7.1.0/output/php/php/fpm/
Installing phpdbg binary: /Users/null/work/php/php-7.1.0/output/bin/
Installing phpdbg man page: /Users/null/work/php/php-7.1.0/output/php/man/man1/
Installing PHP CGI binary: /Users/null/work/php/php-7.1.0/output/bin/
Installing PHP CGI man page: /Users/null/work/php/php-7.1.0/output/php/man/man1/
Installing build environment: /Users/null/work/php/php-7.1.0/output/lib/php/build/
Installing header files: /Users/null/work/php/php-7.1.0/output/include/php/
Installing helper programs: /Users/null/work/php/php-7.1.0/output/bin/
program: phpize
program: php-config
Installing man pages: /Users/null/work/php/php-7.1.0/output/php/man/man1/
page: phpize.1
page: php-config.1
Installing PDO headers: /Users/null/work/php/php-7.1.0/output/include/php/ext/pdo/
发表评论 取消回复