如何在 Ubuntu 上安装 PHP pthreads 扩展?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15782860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install PHP pthreads extension on Ubuntu?
提问by Victor Smirnov
I'd like to install the 'pthreads' PHP extension on Ubuntu. I'm using Ubuntu 12.04.1 LTS. And I can upgrade if needed. I really don't want to compile anything from source. For example recompile PHP from source sounds like a horrible idea to me.
我想在 Ubuntu 上安装“pthreads”PHP 扩展。我正在使用 Ubuntu 12.04.1 LTS。如果需要,我可以升级。我真的不想从源代码编译任何东西。例如,从源代码重新编译 PHP 对我来说听起来是一个可怕的主意。
In my view, the best option is to install this extension with aptitude
command. For example like aptitude install php5-mysql
. Another good idea is to use pecl pecl install pthreads
. But is does not work for me because of the following error:
在我看来,最好的选择是用aptitude
命令安装这个扩展。例如像aptitude install php5-mysql
. 另一个好主意是使用 pecl pecl install pthreads
。但是由于以下错误对我不起作用:
checking checking for ZTS... configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled
正在检查 ZTS... 配置:错误:pthreads 需要 ZTS,请在启用 ZTS 的情况下重新编译 PHP
Let me explain why I don't like the idea to recompile PHP from source:
让我解释一下为什么我不喜欢从源代码重新编译 PHP 的想法:
- I guess I should uninstall original PHP package then and all the dependencies. Because if I compile it over standard PHP then any packages update would overwrite my changes. And yes, another option is to keep PHP from updating. Anyway this introduces some extra work and makes the setup more complicated. We work in the distributed team. And I don't want other people to deal with this complicated setup on production servers.
- I want to install updates on servers. And I don't want to recompile PHP because of security fixes etc.
- I don't want to compile anything on production servers and do this many times. Then I should build my own packages and update them with new versions etc. Sorry but I'm not smart enough to do this. May be in 2-3 years but not now. Because there are a lot of things to keep in mind here. For example how, to replace standard PHP package with custom package while still satisfying all dependencies.
- 我想我应该卸载原来的 PHP 包和所有的依赖项。因为如果我通过标准 PHP 编译它,那么任何包更新都会覆盖我的更改。是的,另一个选择是阻止 PHP 更新。无论如何,这会引入一些额外的工作并使设置更加复杂。我们在分布式团队中工作。而且我不希望其他人在生产服务器上处理这种复杂的设置。
- 我想在服务器上安装更新。而且我不想因为安全修复等原因重新编译 PHP。
- 我不想在生产服务器上编译任何东西并多次这样做。然后我应该构建我自己的包并用新版本等更新它们。抱歉,我不够聪明,无法做到这一点。可能在 2-3 年之后,但不是现在。因为这里有很多事情要记住。例如,如何用自定义包替换标准 PHP 包,同时仍然满足所有依赖项。
Some references:
一些参考:
- Dynamically Configure PHP for Thread Safety --enable-maintainer-zts, or use YUM to install pThreads?
- How to use Pthreads PHP extension (in Ubuntu)- Some talks about what I'm going to do here.
- Building pthreads
- 为线程安全动态配置PHP--enable-maintainer-zts,还是使用YUM安装pThreads?
- 如何使用 Pthreads PHP 扩展(在 Ubuntu 中)- 一些讨论我将在这里做什么。
- 构建线程
This article seems to be old and not actual. I'll keep it for reference only. And I guess it should be read as 'PHP was not thread safe 3 years ago'.
这篇文章似乎是旧的,而不是实际的。我会保留它仅供参考。我想它应该被理解为“3 年前 PHP 不是线程安全的”。
采纳答案by Joe Watkins
ZTS: [Z]end [T]hread [S]afety.
ZTS:[Z]end [T]hread [S]安全。
ZTS is a compile time option that cannot be enabled at runtime. It allows the PHP interpreter, which usually executes in a single thread, to be executed in many, each with their own isolated instance of the interpreter.
ZTS 是一个编译时选项,无法在运行时启用。它允许通常在单个线程中执行的 PHP 解释器可以在多个线程中执行,每个都有自己独立的解释器实例。
The only option for you appears to be a fresh build, and then using package building tools for your distribution.
您的唯一选择似乎是全新构建,然后为您的发行版使用包构建工具。
I'm not able to advise on the creation of a deb directly, however, creating an rpm is quite trivial, https://github.com/krakjoe/spexthere's a starting place for that, you can then use alien to turn an RPM into a deb if you are not able to find out how to create deb packages directly.
我无法直接就创建 deb 提供建议,但是,创建 rpm 非常简单,https://github.com/krakjoe/spex有一个起点,然后您可以使用 Alien 来打开如果您无法找到如何直接创建 deb 包,则将 RPM 转换为 deb。
Building from source is going to be inescapable, unless you can find some repository with a thread safe build of PHP, with a complete build environment. To that end, the information http://pthreads.org/buildingmay be of use to you. It really isn't that hard to build PHP, nor does it take many hours, on modern hardware you can have a build in less than a minute. You can and should take the opportunity to trim the fat from your installation.
从源代码构建将是不可避免的,除非您可以找到一些具有线程安全的 PHP 构建和完整构建环境的存储库。为此,信息http://pthreads.org/building可能对您有用。构建 PHP 真的没有那么难,也不需要很多小时,在现代硬件上,您可以在不到一分钟的时间内完成构建。您可以而且应该借此机会从安装中去除多余的部分。
On a side note, the article you reference about PHP not being thread safe is from 2008, it's very wrong. The core is thread safe, there are a few extensions that are inherently unsafe ( not abstracted badly, but fundamentally unsuitable ).
附带说明一下,您参考的关于 PHP 不是线程安全的文章是 2008 年的,这是非常错误的。核心是线程安全的,有一些扩展本质上是不安全的(不是抽象得不好,但根本不合适)。
回答by Ruslan Osmanov
It seems, Ubuntu doesn't have a package for the thread-safe PHP in the official repositories. Pthreads extension requires ZTS. Thus, you have two options:
看来,Ubuntu 在官方存储库中没有线程安全 PHP 的包。Pthreads 扩展需要 ZTS。因此,您有两个选择:
- compile it yourself:
- find a .deb package somewhere, e.g. repositories of the other Debian-like systems.
- 自己编译:
- 在某处找到一个 .deb 包,例如其他类 Debian 系统的存储库。
I'd compile and package it myself using "checkintsall" utility. Thus, Apt will have ability to keep track of PHP version. I would also request Canonical for a package for ZTS PHP.
我会使用“checkintsall”实用程序自己编译和打包它。因此,Apt 将能够跟踪 PHP 版本。我还要求 Canonical 提供 ZTS PHP 包。