且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-02-23 17:21:14

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

您正在涉足相当高级的 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' \
"$@"