php - 向 MAMP 添加 GMP PHP 扩展

标签 php mamp gmp

尝试将 MAMP 3.4 与当前最新版本的 PHP (5.6.10) 一起使用,但我需要 PHP 扩展 GMP。我的理解是,该扩展不是一个单独的模块,而是需要使用 --with-gmp 完全重新编译 PHP。

正在尝试关注 the guide linked here使用干净的 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

最佳答案

事实证明,您需要来自 httpd 的一些关键文件才能将 php 构建为 Apache 模块(如 MAMP 所要求的)。 MAMP 从安装中忽略这些文件。

  1. http://mirror.reverse.net/pub/apache/httpd/ 下载 Apache 确保您下载的版本与 MAMP 发行版中的版本相同。您可以从命令行键入 /Applications/MAMP/Library/bin/httpd -version 以找出答案。
  2. 解压缩发行版并 cd 到其中。
  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 存储的所有版本。就我而言,我是 build 5.6.10。
  2. 解压缩发行版并 cd 到其中。
  3. 在某处创建一个文件夹来存储构建结果。我再次将我的结果放在桌面上的 ~/Desktop/build/php 中。
  4. 使用 ./configure --with-apxs2=/Applications/MAMP/Library/bin/apxs --prefix=/Users/[username]/Desktop/build/之类的东西配置 PHP 以构建您需要的内容php --with-openssl --without-iconv。如果你愿意,你可以查看你要替换的版本的现有 phpinfo 页面,以找出它是用什么编译的。请记住,某些模块将要求您从其他一些库的源副本构建。
  5. makemake install
  6. 您现在拥有一个可与 MAMP 一起使用的 php 共享对象。关闭 MAMP,将 ~/Dekstop/build/httpd/modules/libphp5.so 复制到 /Applications/MAMP/bin/php/php5.6.10/modules 并重新启动它。保留一份以前的 libphp5.so 文件的副本是个不错的主意,以防万一。

关于php - 向 MAMP 添加 GMP PHP 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32830551/

相关文章:

c - Diffie-Hellman 中参数的选择

php - 如何每15秒检查和更改mysql中的数据?

尝试从 start_date + 持续时间生成 end_date 时 MySQL 触发错误

MySQL 5.6 未启动(将 MAMP 2 迁移到 MAMP 4)

c++ - 在 linux 环境中,如何在 C++ 中将 X 文件作为数字读入 RAM?

c++ - 最好的跨平台(可移植)任意精度数学库

php - 带有 SSL 证书的 cURL 失败 : error 58 unable to set private key file

php - 在 yii 1 web 应用程序中查看 url 而不是 id 上的文章标题以获得 SEO 漂亮的 url

php - 如何使用 php 验证 Apple IAP 收据?

php - kohana 框架无法在 Linux 服务器上加载模块,而在 mamp 上完美加载模块