在 Ubuntu 服务器上安装 PHP pthreads 的问题

问题描述:

我正在尝试在运行 PHP 版本 5.5.8-3+sury.org~precise+2 的 Ubuntu 12.04 服务器上安装 pthread.据我所知,这只是通过 apt-get 进行的标准安装.

I am trying to install pthreads on my Ubuntu 12.04 server that is running PHP Version 5.5.8-3+sury.org~precise+2. To my knowledge this was just a standard installation via apt-get.

然后我尝试运行

sudo pecl install pthreads

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

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

我知道这意味着 PHP 没有使用 --enable-maintiner-zts ./config 标志编译.

I understand that this means PHP was not compiled with the --enable-maintiner-zts ./config flag.

我不知道怎么做的是用这个标志重新编译 PHP,然后覆盖我当前的 PHP 安装,希望不会破坏任何东西.

What I DON'T know how to do is recompile PHP with this flag and then overwrite my current PHP installation, hopefully without breaking anything.

我已经对这个主题进行了一些谷歌搜索,但我发现的少数指南非常高级、陈旧或不是很完整,遗憾的是,我在 Linux 方面仍然有点新手.

I have done some googling on the subject but the few guides I have found are extremely high level, old, or not very complete, and sadly I am still somewhat of a novice when it comes to Linux.

把你所有的借口都放在一个盒子里……烧掉这个盒子,然后忘记它们.

您正在涉足相当高级的 PHP,并且已经正确识别了问题...不要害怕,只需破解...

You are dabbling in rather advanced PHP, and have already identified correctly the problem ... don't be scared, just crack on ...

这里有一些关于配置 PHP 以覆盖您的安装的漫谈......

Here's some ramblings about configuring PHP to overwrite your installation ...

假设我在/usr 中有 PHP,在/etc/php.d 中有 scandir,在/etc/php.ini 中有配置

Lets say I have PHP at /usr, scandir at /etc/php.d and configuration at /etc/php.ini

./configure --prefix=/usr --bindir=/usr/bin --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d

最小配置会覆盖我的安装,我已经包含了 --bindir 因为通过设置单个配置选项,您可以隔离 PHP 安装,例如,/opt/php-zts.

That minimal configuration would overwrite my installation, I have included --bindir because by setting that single configuration option you are able to isolate an installation of PHP at, for example, /opt/php-zts.

您至少需要附加选项

--enable-maintainer-zts

您应该检查您当前的安装,记下已启用的扩展程序,然后从默认设置开始.

You should inspect your current installation, make a note of the extensions enabled and just work your way up from the default.

如果一个扩展无法构建,通常是因为扩展所包装的库的头文件在你的系统上不可用,通常是使用你的发行版包安装 dev 或 devel 包manager 将允许构建成功.

If an extension should fail to build, it will usually be because the headers for the library the extension is wrapping are not available on your system, it's usually the case that installation of the dev, or devel package, using your distros package manager will allow the build to succeed.

一旦你有了一个完整的构建版本,最好将 config.nice 复制到一个合理的地方,以便你将来拥有它.

Once you have a working full build, its good advice to copy config.nice to somewhere sensible so that you have it for the future.

最后,实际上覆盖系统上的安装并不总是可取的,其他软件可能正在使用它,所以我通常说最好隔离安装,这是我机器上隔离安装的 config.nice 逐字记录:

Lastly it's not always desirable to actually overwrite the installation on your system, other software may be using that, so I usually say it's better to isolate an installation, here's a config.nice verbatim from an isolated install on my machine:

#! /bin/sh
#
# Created by configure

'./configure' \
'--with-apxs2=/opt/php-zts/bin/apxs' \
'--prefix=/opt/php-zts' \
'--bindir=/opt/php-zts/bin' \
'--with-config-file-dir=/opt/php-zts' \
'--with-config-file-scan-dir=/opt/php-zts/modules.d/' \
'--with-curl=shared,/usr' \
'--with-zlib' \
'--with-libxml2' \
'--enable-simplexml' \
'--with-mysql=mysqlnd' \
'--with-pdo-mysql=mysqlnd' \
'--enable-gd-native-ttf' \
'--with-mysqli' \
'--disable-phar' \
'--enable-shared' \
'--enable-maintainer-zts' \
'--enable-opcache' \
'--enable-sockets' \
'--with-curl=shared' \
'--enable-pcntl=shared' \
'--enable-mbstring' \
"$@"