在没有提示的情况下安装 PECL 模块
我刚刚在 Ubuntu Natty 上从源代码安装了 PHP。
我正在尝试使用 PECL 安装其他模块,例如 APC 和 Memcache。我正在使用这样的东西:
pecl install apc
但是,我收到提示要求我确认事情。
如何使用 pecl 命令只接受默认值?我在留言板上看到类似这样的内容: printf "yes\n" | pecl 安装 pecl_http
。然而,在 APC 的情况下,对于默认为“否”的情况,这将回答“是”(我认为)。
I just installed PHP on Ubuntu Natty from source.
I'm trying to use PECL to install additional modules like APC and Memcache. I'm using something like this:
pecl install apc
However, I get prompts asking me to confirm things.
How can I use the pecl command to just accept the defaults? I saw something like this on a message board: printf "yes\n" | pecl install pecl_http
. However, in the case of APC this would answer yes for things where the default is no (I think).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下代码似乎可以正常工作:
您还可以将 apc 替换为任何其他 PECL 包。
干杯。
The following code seems to work ok:
You can also replace apc with any other PECL package.
Cheers.
“yes”命令的作用不仅仅是键入“yes”;它可以一遍又一遍地输入您想要的任何内容。包括一个空行,这是接受默认值的好方法。
我自己只需要这个,所以这对我来说很有效:
The "yes" command can do more than just type "yes"; it can type anything you want, over and over. Including an empty line, which is a good way to accept defaults.
I just needed this myself, so here is what worked well for me:
如果您不想对每个提示给出相同的答案(“是”、“否”或“”),您可以使用
--configureoptions
为每个选项设置特定值(请参阅PECL 手册)。您需要找到包的 package.xml 文件以查看哪些选项是可配置的。例如,对于
memcached
包,您可以转到此处:https://github.com/php-memcached-dev/php-memcached/blob/master/package.xml
搜索
标记,在本例中为:然后您可以将这些选项传递给安装命令,如下所示:
If you don't want give the same answer for every single prompt ("yes", "no", or ""), you can use
--configureoptions
to set specific values for each option (see the PECL manual).You'll want to find your package's package.xml file to see what options are configurable. As an example, for the
memcached
package, you'd go here:https://github.com/php-memcached-dev/php-memcached/blob/master/package.xml
Search for the
<configureoption>
tags, which in this case are:You can then pass these options along to the install command like so:
Obinwanne 的 Hill 答案为我提供了答案,所以我不会在这里提供任何新内容,但以下内容似乎是绝对最短的,也没有任何花哨的工具。
Obinwanne's Hill answer nailed it for me, so I'm not providing anything new here, but the following seems like the absolute shortest also without any fancy tools.