PHP 是否使用线程安全
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17616387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP Use thread safe or not
提问by MarkO
I am building a web server install for a production server on a windows 2008 R2 64 bit server
我正在为 Windows 2008 R2 64 位服务器上的生产服务器构建 Web 服务器安装
I have installed Apache 2.4 64 bit and that is working fine
我已经安装了 Apache 2.4 64 位并且运行良好
Next step, PHP
下一步,PHP
I have read about the differences between thread safe and not but just cant seem to grasp which I should be using (and why).
我已经阅读了线程安全与线程安全之间的差异,但似乎无法理解我应该使用哪个(以及为什么)。
Can anybody confirm which PHP Install I should use with my current setup?
任何人都可以确认我应该在当前设置中使用哪个 PHP 安装?
回答by jh314
You should look at the PHP docs:
Thread Safety means that binary can work in a multithreaded webserver context, such as Apache 2 on Windows. Thread Safety works by creating a local storage copy in each thread, so that the data won't collide with another thread.
So what do I choose? If you choose to run PHP as a CGI binary, then you won't need thread safety, because the binary is invoked at each request. For multithreaded webservers, such as IIS5 and IIS6, you should use the threaded version of PHP.
线程安全意味着二进制文件可以在多线程网络服务器上下文中工作,例如 Windows 上的 Apache 2。线程安全的工作原理是在每个线程中创建一个本地存储副本,这样数据就不会与另一个线程发生冲突。
那我选择什么?如果您选择将 PHP 作为 CGI 二进制文件运行,那么您将不需要线程安全,因为该二进制文件在每次请求时都会被调用。对于多线程 Web 服务器,例如 IIS5 和 IIS6,您应该使用 PHP 的线程版本。
So for example, if you use FastCGI
with Apache, go for the non-thread safe, and if you use LoadModule, go for the thread-safe version.
因此,例如,如果您FastCGI
与 Apache 一起使用,请选择非线程安全的,如果您使用 LoadModule,请选择线程安全的版本。
回答by Aaron Harker
"With Apache you have to use the Thread Safe (TS) versions of PHP." from the download page if anyone else is ever looking.
“对于 Apache,您必须使用 PHP 的线程安全 (TS) 版本。” 如果其他人正在寻找,请从下载页面。