MAMP自带的PHP版本在编译的时候是没有加上--enable-debug选项的,于是我打算自己重新编译一下PHP方便自己在进行PHP扩展研究的时候可以用gdb来查看core dump文件。
首先使用MAMP中的php版本查看phpinfo()
得到了MAMP在编译时候的参数
--more--
并且在后面加上了--enable-debug选项
sudo './configure' '--with-mysql=mysqlnd' '--with-gd' '--with-jpeg-dir=/Applications/MAMP/Library' '--with-png-dir=/Applications/MAMP/Library' '--with-zlib' '--with-zlib-dir=/Applications/MAMP/Library' '--with-freetype-dir=/Applications/MAMP/Library' '--prefix=/Applications/MAMP/bin/php/php5.5.26' '--exec-prefix=/Applications/MAMP/bin/php/php5.5.26' '--sysconfdir=/Applications/MAMP/bin/php/php5.5.26/conf' '--with-config-file-path=/Applications/MAMP/bin/php/php5.5.26/conf' '--enable-ftp' '--enable-gd-native-ttf' '--with-bz2=/usr' '--with-ldap' '--with-mysqli=mysqlnd' '--with-t1lib=/Applications/MAMP/Library' '--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-sockets' '--enable-bcmath' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2007f' '--enable-soap' '--with-kerberos' '--enable-calendar' '--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-exif' '--with-libxml-dir=/usr/include' '--with-gettext=shared,/Applications/MAMP/Library' '--with-xsl=/Applications/MAMP/Library' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg' '--with-mcrypt=shared,/Applications/MAMP/Library' '--with-openssl' '--enable-zip' '--with-iconv=/Applications/MAMP/Library' '--enable-opcache' '--enable-cgi' '--enable-intl' '--with-icu-dir=/Applications/MAMP/Library' '--with-tidy=shared' '--enable-wddx' '--with-libexpat-dir=/Applications/MAMP/Library' --enable-debug
将重新下载的php对应版本新建了一个目录,解压在了以下的文件夹中
/Applications/MAMP/bin/php/php5.5.26/include/php
第一次使用上面的参数第一次编译报错:
configure: error: Cannot find OpenSSL's
用
brew link openssl --forece
再编译,又获得如下错误
configure: error: jpeglib.h not found
使用brew安装jpeglib
sudo brew install jpeglib
接下来又报错
configure: error: png.h not found
sudo brew install t1lib
报错
configure: error: Cannot locate header file libintl.h
用以下来解决
sudo brew install gettext
1) 安装 gettext:
brew install gettext
2) 编辑configure文件
将:
for i in $PHP_GETTEXT /usr/local /usr ; do
更改为:
for i in $PHP_GETTEXT /usr/local /usr /usr/local/opt/gettext; do
3)重新运行 ./configure
报错
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information
安装
sudo brew install imap-uw
报错
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
安装
sudo brew install libmcrypt
报错
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
安装
sudo brew install PostgreSQL
之后
sudo make && sudo make install
会报错找不到libxml/parse.h
改成
/usr/include/libxml2
安装iconv
sudo brew install homebrew/dupes/libiconv
在修复libiconv报错的时候,网上一篇文章写移动/use/lib/目录底下的libiconv.*移动到其他目录,替换刚刚安装的libiconv来交叉编译,结果刚移动系统就崩溃了。这个库应该是系统很多程序调用的库, 花了一晚上重装了个系统,打算明天用docker来装个PHP环境。