繁体   English   中英

pecl install - 如何指定选项?

[英]pecl install - how to specify options?

我正在尝试使用 pecl 为 PHP 安装event扩展。 在安装过程中,我收到几个提示:

Enable internal debugging in Event [no] : 
Enable sockets support in Event [yes] : 
libevent installation prefix [/usr] : 
Include libevent's pthreads library and enable thread safety support in Event [no] : 
Include libevent protocol-specific functionality support including HTTP, DNS, and RPC [yes] : 
Include libevent OpenSSL support [yes] : 
PHP Namespace for all Event classes [no] : 
openssl installation prefix [no] : 

但是只有在交互模式下才会发生这种情况。 我需要在没有交互的情况下执行此操作,例如在 Dockerfile 中。 默认值对我不起作用,因此我需要使用命令行选项更改它们。 如何?

请记住,我需要对每个问题做出不同的回答,所以yes '' | pecl install ... yes '' | pecl install ...根本不起作用。 还有一个问题需要一条路径,而不是是/否。

pecl 的非交互模式尚不可用。 可以用yes命令补充。 命令输出肯定的直到终止。

您可以像这样对管道使用yesyes '' | pecl install ... yes '' | pecl install ...

编辑:如果您不需要每次迭代都输出 yes,只需回显您的答案,例如echo 'yes\n no\n ...' | pecl install ... echo 'yes\n no\n ...' | pecl install ...

更多编辑:如果您在 docker 中使用此解决方案,则在 Dockerfile 中您可以使用命令 docker docker-php-ext-install event ,然后使用 docker docker-php-ext-configure ...

这些天我正在使用 PHP workerman ,并且在 Docker 中安装event扩展时也遇到了这个问题。 按照工人的文件, event应配置为:

  • 不包括 libevent OpenSSL 支持
  • 为所有事件类启用 PHP 命名空间

这意味着对于交互式问题应该输入no包括 libevent OpenSSL support [ yes Include libevent OpenSSL support [yes] :并且对于Include libevent OpenSSL support [yes] :输入 yes ,而对于其他问题只需要enter

您可以尝试这个解决方案(也可以在Dockerfile RUN放在首位):

printf "\n\n\n\n\nno\nyes\n\n" | pecl install event

echo '\n\n\n\n\nno\nyes\n\n'不起作用,因为它似乎没有用作交互式答案,它将整个字符串作为配置参数值发送,您可能会看到:

running: /tmp/pear/temp/event/configure --with-php-config=/usr/bin/php-config --enable-event-debug=\n\n\n\n\nno\nyes\n\n ...

现在可以通过--configureoptions将配置选项传递给pecl install

您需要找到您的包的 package.xml 文件以查看哪些选项是可配置的。 对于event套餐,您将前往此处:

https://bitbucket.org/osmanov/pecl-event/src/master/package.xml

搜索<configureoption>标记,在本例中为:

<configureoption default="no" name="enable-event-debug" prompt="Enable internal debugging in Event"/>
<configureoption default="yes" name="enable-event-sockets" prompt="Enable sockets support in Event"/>
<configureoption default="/usr" name="with-event-libevent-dir" prompt="libevent installation prefix"/>
<configureoption default="no" name="with-event-pthreads" prompt="Include libevent's pthreads library and enable thread safety support in Event"/>
<configureoption default="yes" name="with-event-extra" prompt="Include libevent protocol-specific functionality support including HTTP, DNS, and RPC"/>
<configureoption default="yes" name="with-event-openssl" prompt="Include libevent OpenSSL support"/>
<configureoption default="no" name="with-event-ns" prompt="PHP Namespace for all Event classes"/>
<configureoption default="yes" name="with-openssl-dir" prompt="openssl installation prefix"/>

然后,您可以将这些选项传递给安装命令,如下所示:

pecl install --configureoptions 'enable-event-debug="no" with-event-libevent-dir="/my/dir" with-event-ns="yes"' event

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM