向 MAMP 添加 GMP PHP 扩展

3
尝试使用MAMP 3.4与最新版本的PHP(目前为5.6.10),但我需要PHP扩展GMP。我的理解是该扩展不是独立模块,而需要使用--with-gmp重新编译完整的PHP。
尝试按照此处链接的指南操作,使用干净的5.6.10源代码,但我遇到了与OP相同的错误。
Didiers-MacBook-Pro:php-5.6.10 didier$ ./configure --with-mysql=/Applications/MAMP/Library --with-apxs2=/Applications/MAMP/Library/bin/apxs --with-gd --with-jpeg-dir=/Applications/MAMP/Library --with-png-dir=/Applications/MAMP/Library --with-zlib --with-freetype-dir=/Applications/MAMP/Library --prefix=/Applications/MAMP/bin/php5 --exec-prefix=/Applications/MAMP/bin/php5 --sysconfdir=/Applications/MAMP/conf/php5 --with-soap --with-config-file-path=/Applications/MAMP/conf/php5 --enable-track-vars --enable-bcmath --enable-ftp --enable-gd-native-ttf --with-bz2=/usr --with-ldap --with-mysqli=/Applications/MAMP/Library/bin/mysql_config --with-sqlite --with-ttf --with-t1lib=/Applications/MAMP/Library --enable-mbstring=all --with-curl=/Applications/MAMP/Library --enable-dbx --enable-sockets --enable-bcmath --with-imap=shared,/Applications/MAMP/Library/lib/imap-2006i --enable-soap --with-kerberos --enable-calendar --with-pgsql=shared,/Applications/MAMP/Library/pg --enable-dbase --enable-exif --with-libxml-dir=/Applications/MAMP/Library --with-gettext=shared,/Applications/MAMP/Library --with-xsl=/Applications/MAMP/Library --with-pdo-mysql=/Applications/MAMP/Library --with-pdo-pgsql=shared,/Applications/MAMP/Library/pg --with-mcrypt=shared,/Applications/MAMP/Library --with-openssl --with-gmp --without-iconv --prefix=/Users/Didier/Desktop/result
configure: WARNING: unrecognized options: --with-soap, --enable-track-vars, --with-sqlite, --with-ttf, --enable-dbx, --enable-dbase
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 build system type... x86_64-apple-darwin14.5.0
checking host system type... x86_64-apple-darwin14.5.0
checking target system type... x86_64-apple-darwin14.5.0
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 how to run the C preprocessor... cc -E
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 minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether ln -s works... yes
checking for system library directory... lib
checking whether to enable runpaths... yes
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for bison... bison -y
checking for bison version... invalid
configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 2.3, min: 204, excluded: 3.0).
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking whether to enable computed goto gcc extension with re2c... no
checking whether cc supports -no-cpp-precomp... yes
checking whether to force non-PIC code in shared modules... no
checking whether /dev/urandom exists... yes
checking for pthreads_cflags... 
checking for pthreads_lib... 

Configuring SAPI modules
checking for AOLserver support... no
checking for Apache 1.x module support via DSO through APXS... no
checking for Apache 1.x module support... no
checking whether to enable Apache charset compatibility option... no
checking for Apache 2.0 filter-module support via DSO through APXS... no
checking for Apache 2.0 handler-module support via DSO through APXS... 

Sorry, I cannot run apxs.  Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

The output of /Applications/MAMP/Library/bin/apxs follows:
cannot open /Applications/MAMP/Library/build/config_vars.mk: No such file or directory at /Applications/MAMP/Library/bin/apxs line 217.
configure: error: Aborting
1个回答

4
原来构建PHP作为Apache模块(如MAMP所需),需要一些关键文件从httpd中获取。MAMP在安装时省略了这些文件。
  1. http://mirror.reverse.net/pub/apache/httpd/下载Apache,确保您下载的版本与MAMP分发的版本相同。您可以在命令行中输入/Applications/MAMP/Library/bin/httpd -version来查找版本。
  2. 解压分发包并进入其中。
  3. 创建某个文件夹以存储构建结果。我们将把文件放在桌面上,类似于~/Desktop/build/httpd
  4. 下一步是构建httpd。像./configure --prefix=/Users/[username]/Desktop/build/httpd --enable-so这样的语句应该就能完成了。请注意,安装路径需要是绝对路径,因此我们不能在此处使用波浪号字符。
  5. 一旦配置完成且没有任何错误,则进行make,然后进行make install。现在,您已经编译了一个源自Apache的服务器。祝贺!
  6. 从该构建中,我们需要获取缺失在MAMP安装中的文件。实际上,这是位于~/Desktop/build/httpd/build的单个目录。将其复制到/Applications/MAMP/Library中,您现在将能够构建PHP而不会出现上述错误消息。请确保复制目录而不是移动它。您稍后需要它进行PHP编译。
下一步是编译PHP本身:
  1. http://php.net/downloads.php 下载 PHP 源代码。确保下载的版本与您要替换的版本相同(您可以在 /Applications/MAMP/bin/php 中找到 MAMP 存储的所有版本)。在我的情况下,我正在构建 5.6.10 版本。
  2. 解压分发包并进入其中。
  3. 创建一个文件夹来存储构建结果。再次强调,我将我的结果放在桌面上的 ~/Desktop/build/php 中。
  4. 使用类似 ./configure --with-apxs2=/Applications/MAMP/Library/bin/apxs --prefix=/Users/[username]/Desktop/build/php --with-openssl --without-iconv 的命令配置 PHP,以构建所需内容。如果您愿意,您可以查看要替换的版本的现有 phpinfo 页面,了解它是如何编译的。请记住,某些模块需要您从源代码构建其他某些库的副本。
  5. 运行 makemake install
  6. 现在,您有了一个可与 MAMP 一起使用的共享对象作为 PHP。关闭 MAMP,将 ~/Dekstop/build/httpd/modules/libphp5.so 复制到 /Applications/MAMP/bin/php/php5.6.10/modules 并重新启动。为了以防万一,保留先前的 libphp5.so 文件的备份是个好主意。

我需要在哪里执行make和make install命令?它无法在~/Desktop/build/httpd/或下载的目录中工作... - Daniel Gelling
哪一个?你应该总是在与 ./configure 相同的目录中执行这些操作。 - Didier Malenfant
这对我也起作用,但当我从桌面上删除了构建文件夹时,它停止工作了。这不是真正的问题,只是要记住如果你想让它继续工作! - Craig Brown

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接