如何将配置选项传递给 phpenv 安装

Gor*_*don 2 php

我想通过phpenv安装 PHP ,并启用 ZTS 和调试符号。在手动安装中,我会通过传递--enable-debug--enable-maintainer-zts配置选项来做到这一点。

如何将这些选项传递给 phpenv?

Gor*_*don 6

打字phpenv install --help打印

Usage: phpenv install [--ini|-i <environment>] <version>
       phpenv install [--ini|-i <environment>] <definition-file>
       phpenv install -l|--list
       phpenv install -V|--version

 -l/--list     List all available versions
 -V/--version  Show version of php-build

For detailed information on installing PHP versions with
php-build, including a list of environment variables for adjusting
compilation, see: https://github.com/php-build/php-build
Run Code Online (Sandbox Code Playgroud)

所以没有命令行标志来传递这些选项。但最后一段重定向到https://github.com/php-build/php-build,这是 phpenv 用来安装 php 的。该 repo 中的自述文件没有列出任何环境变量,但深入研究源代码man 文件会发现以下内容:

环境

  • PHP_BUILD_DEBUG, 将此设置yes为触发set -x 呼叫。这个回显是脚本的所有发出的 shell 命令。
  • PHP_BUILD_XDEBUG_ENABLE=on|off(默认:),on设置为off注释掉启用 XDebug 的行,在生成的xdebug.ini.
  • PHP_BUILD_CONFIGURE_OPTS, 附加配置选项列表。
  • PHP_BUILD_ZTS_ENABLE=on|off(默认off:),为构建启用 Zend 线程安全
  • PHP_BUILD_INSTALL_EXTENSION 见[扩展]部分。

所以用ZTS和调试模式安装PHP,需要使用

PHP_BUILD_ZTS_ENABLE=yes \
PHP_BUILD_CONFIGURE_OPTS="--enable-debug" \
phpenv install 7.1.0
Run Code Online (Sandbox Code Playgroud)