编译参数

sudo './configure' '--prefix=/usr/local/php7' '--with-config-file-path=/usr/local/php7/etc' '--with-pdo-mysql' '--with-mysqli' '--with-bz2=/usr/local/Cellar/bzip2/1.0.6_1' '--with-curl=/usr/local/curl' '--with-openssl=/usr/local/Cellar/openssl/1.0.2l/' '--with-zlib' '--without-pdo-sqlite' '--without-sqlite3' '--enable-fpm' '--enable-mbstring' '--enable-zip' '--disable-cgi' '--disable-ipv6' '--with-gd' '--with-png-dir=/usr/local/libpng/' '--with-jpeg-dir=/usr/local/jpeg6/' '--with-iconv=/usr/local/libiconv' '--enable-exif' '--with-readline=/usr/local/Cellar/readline/7.0.3_1' '--enable-calendar' '--enable-bcmath' '--enable-sockets' '--enable-pcntl' '--enable-opcache' --with-readline=/usr/local/Cellar/readline/7.0.3_1


其中一些软件是手动编译的,安装包随便找linux镜像站即可下载,也可以通过 brew安装


执行 make 中途编译出错

提示

Undefined symbols for architecture x86_64:
  "_append_history", referenced from:
      _readline_shell_run in readline_cli.o
  "_history_list", referenced from:
      _zif_readline_list_history in readline.o
  "_libiconv", referenced from:
      _do_convert in gdkanji.o
      _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
      ...
  "_libiconv_close", referenced from:
      _do_convert in gdkanji.o
      _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
      ...
  "_libiconv_open", referenced from:
      _do_convert in gdkanji.o
      _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
      ...
  "_rl_mark", referenced from:
      _zif_readline_info in readline.o
  "_rl_pending_input", referenced from:
      _zif_readline_info in readline.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


解决方法:

修改 configure 后生成的 Makefile 文件

找到 EXTRA_LIBS 变量

删除 -liconv 

增加

/usr/local/libiconv/lib/libiconv.dylib /usr/local/Cellar/readline/7.0.3_1/lib/libhistory.dylib /usr/local/Cellar/readline/7.0.3_1/lib/

修改后

EXTRA_LIBS = -lcrypto -lssl -lcrypto -lz -lresolv -lreadline -lncurses /usr/local/libiconv/lib/libiconv.dylib -lpng -lz -ljpeg -lbz2 -lz -lcrypto -lssl -lcrypto -lm -lxml2 -lz -licucore -lm -lcurl -lldap -lz -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm /usr/local/Cellar/readline/7.0.3_1/lib/libhistory.dylib /usr/local/Cellar/readline/7.0.3_1/lib/libreadline.dylib



执行 sudo make 


然后 sudo make install  

LixinDeMac:php-7.2.1 lx$ /usr/local/php7/bin/php -v
PHP 7.2.1 (cli) (built: Jan 29 2018 18:22:19) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
LixinDeMac:php-7.2.1 lx$ /usr/local/php7/bin/php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
SimpleXML
sockets
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
LixinDeMac:php-7.2.1 lx$




阅读:1450