简体   繁体   English

使用--enable-maintainer-zts编译PHP时的缺点或副作用(要使用php pthread)

[英]Drawbacks or side-effects when compiling PHP with --enable-maintainer-zts (to use php pthread)

I have a web application and is running fine with PHP 5.5.5 on a production environment. 我有一个Web应用程序,并且在生产环境中与PHP 5.5.5正常运行。

On the same server now I need to run some PHP scripts that make use of php pthread (v. 2.0.10) 现在,我需要在同一台服务器上运行一些使用php pthread(v。2.0.10)的PHP脚本。

Is it safe to rebuild php with --enable-maintainer-zts (to allow use of pthreads) and use the same executable both for the web application and the CLI scripts that use php-pthread ? 它是安全的重建与PHP --enable-maintainer-zts (允许使用并行线程),并使用相同的可执行文件为Web应用程序和使用PHP的并行线程的CLI脚本

Or should I make two builds of PHP: php , php-zts and use the former for the web app and the latter for the CLI scripts ? 还是我应该制作两个PHP版本: phpphp-zts并将前一个用于Web应用程序并将后一个用于CLI脚本?

As --enable-maintainer-zts is not enabled by default I assume it have some drawbacks or worse (as I have read here https://github.com/travis-ci/travis-ci/issues/985 ) may introduce misbehaviours (bugs). 由于默认情况下未启用--enable-maintainer-zts因此我认为它有一些缺点或更糟(如我在此处阅读的内容https://github.com/travis-ci/travis-ci/issues/985 )可能会引起不良行为(错误)。

The web stack is nginx + php-fpm + mySql on Mac OS X 10.9.5. 在Mac OS X 10.9.5上,Web堆栈为nginx + php-fpm + mySql

I want it to be clear: phtread will not be used by the web application scripts. 我希望清楚一点:Web应用程序脚本不会使用phtread Only by the CLI scripts. 仅通过CLI脚本。

From http://www.phpinternalsbook.com/build_system/building_php.html 来自http://www.phpinternalsbook.com/build_system/building_php.html

(emphasis mine) (强调我的)

--enable-debug enables debug mode --enable-debug启用调试模式

[...] [...]

--enable-maintainer-zts enables thread-safety. --enable-maintainer-zts启用线程安全性。

[...] [...]

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 seem not harmful but affects performances. --enable-maintainer-zts似乎无害,但会影响性能。 So it's definitely not advisable in a production environment. 因此,在生产环境中绝对不建议这样做。

A separate build of PHP with --enable-maintainer-zts in order to use php pthread in CLI scripts is the appropriate way to go. 为了在CLI脚本中使用php pthread,使用--enable-maintainer-zts单独构建PHP是合适的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM