我有一个网络应用程序,在生产环境中使用 PHP 5.5.5 运行良好。
现在我需要在同一台服务器上运行一些使用 php pthread (v. 2.0.10) 的 PHP 脚本
使用 --enable-maintainer-zts
重建 php 是否安全(以允许使用 pthreads)并使用相同的可执行文件两者 对于使用 php-pthread ?
或者我应该构建两个 PHP:php
、php-zts
并将前者用于 Web 应用程序,将后者用于 CLI 脚本?
由于默认情况下未启用 --enable-maintainer-zts
我认为它有一些缺点或更糟(正如我在这里阅读的 https://github.com/travis-ci/travis-ci/issues/985 )可能会引入不当行为(错误)。
在 Mac OS X 10.9.5 上,Web 堆栈是 nginx + php-fpm + mySql。
我想明确一点:phtread 将不会 由网络应用程序脚本使用。仅通过 CLI 脚本。
最佳答案
来自 http://www.phpinternalsbook.com/build_system/building_php.html
(强调我的)
--enable-debug
enables debug mode[...]
--enable-maintainer-zts
enables thread-safety.[...]
you should not use either of these options if you want to perform performance benchmarks for your code, as both can cause significant and asymmetrical slowdowns.
--enable-maintainer-zts
似乎无害但会影响性能。所以在生产环境中绝对不可取。
为了在 CLI 脚本中使用 php pthread,使用 --enable-maintainer-zts
单独构建 PHP 是合适的方法。
关于php - 使用 --enable-maintainer-zts 编译 PHP 时的缺点或副作用(使用 php pthread),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35895018/