如何在Ubuntu上安装PHP pthreads扩展? [英] How to install PHP pthreads extension on Ubuntu?

查看:268
本文介绍了如何在Ubuntu上安装PHP pthreads扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Ubuntu上安装'pthreads'PHP扩展.我正在使用Ubuntu 12.04.1 LTS.如果需要,我可以升级.我真的不想从源代码编译任何东西.例如,从源代码重新编译PHP听起来对我来说是一个可怕的想法.

在我看来,最好的选择是使用aptitude命令安装此扩展.例如aptitude install php5-mysql.另一个好主意是使用pecl pecl install pthreads.但是由于以下错误,它对我不起作用:

正在检查ZTS ...配置:错误:pthreads需要ZTS,请在启用ZTS的情况下重新编译PHP

让我解释一下为什么我不喜欢从源代码重新编译PHP的想法:

  • 我想我应该先卸载原始的PHP软件包,然后卸载所有依赖项.因为如果我通过标准PHP进行编译,则任何软件包更新都将覆盖我的更改.是的,另一个选择是阻止PHP更新.无论如何,这引入了一些额外的工作,并使设置更加复杂.我们在分布式团队中工作.而且我不希望其他人在生产服务器上处理这种复杂的设置.
  • 我想在服务器上安装更新.而且由于安全性修复等原因,我不想重新编译PHP.
  • 我不想在生产服务器上编译任何东西,并且要做很多次.然后,我应该构建自己的软件包并使用新版本等对其进行更新.对不起,但我不够聪明,无法做到这一点.可能会在2-3年内,但现在不会.因为这里有很多事情要牢记.例如,如何在仍满足所有依赖性的情况下,用自定义程序包替换标准的PHP程序包.

一些参考文献:

这篇文章似乎是过时的而不是实际的.我将其保留仅供参考.而且我想应该把它读为"PHP 3年前不是线程安全的".

解决方案

ZTS:[Z]结束[T]读取[S]安全性

.

ZTS是一个编译时选项,无法在运行时启用.它允许通常在单个线程中执行的PHP解释器在很多情况下执行,每个解释器都具有各自独立的解释器实例.

您唯一的选择似乎是重新构建,然后使用软件包构建工具进行分发.

我无法直接建议创建deb,但是,创建rpm非常简单, https://github.com/krakjoe/spex 有一个开始的地方,如果您无法找到直接创建deb软件包的方法,则可以使用Alien将RPM转换为deb./p>

将无法避免从源代码进行构建,除非您可以找到具有线程安全的PHP构建以及完整构建环境的某些存储库.为此,您可能会使用 http://pthreads.org/building 信息.实际上,构建PHP并不难,也不需要花费很多时间,在现代硬件上,您可以在不到一分钟的时间内完成构建.您可以并且应该借此机会减少安装中的脂肪.

顺便提一句,您引用的有关PHP线程不安全的文章是2008年写的,这是非常错误的.核心是线程安全的,有一些扩展本质上是不安全的(不是很糟糕的抽象,但是从根本上来说是不合适的).

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.

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:

checking checking for ZTS... configure: error: pthreads requires ZTS, please re-compile PHP with ZTS enabled

Let me explain why I don't like the idea to recompile PHP from source:

  • 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.

Some references:

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'.

解决方案

ZTS: [Z]end [T]hread [S]afety.

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.

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/spex there'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.

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/building may 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.

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 ).

这篇关于如何在Ubuntu上安装PHP pthreads扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆