PHP5 non-thread-safe和thread-safe的区别

None-Thread Safe就是非线程安全,在执行时不进行线程(thread)安全检查;
Thread Safe就是线程安全,执行时会进行线程(thread)安全检查,以防止有新要求就启动新线程的 CGI 执行方式耗尽系统资源。php

再来看PHP的两种执行方式:ISAPI和FastCGI。
FastCGI执行方式是以单一线程来执行操做,因此不须要进行线程的安全检查,除去线程安全检查的防御反而能够提升执行效率,因此,若是是以 FastCGI(搭配IIS)执行 PHP ,都建议下载执行 non-thread safe 的 PHP (PHP 的二进位档有两种包装方式:msi 、zip ,请下载 zip 套件)。
而线程安全检查正是为ISAPI方式的PHP准备的,由于有许多php模块都不是线程安全的,因此须要使用Thread Safe的PHP(搭配apache)。web

若是你还搞不清楚,那么只需知道你是php+apache仍是php+iis组合
non-thread-safe 非 线程安全与IIS搭配环境
thread-safe  线程安全 与apache搭配环境apache

 

Which version do I choose?

IIS

If you are using PHP as FastCGI with IIS you should use the Non-Thread Safe (NTS) versions of PHP.安全

Apache

Please use the Apache builds provided by Apache Lounge. They provide VC9, VC11 and VC14 builds of Apache for x86 and x64. We use their binaries to build the Apache SAPIs.ide

If you are using PHP as module with Apache builds from apache.org (not recommended) you need to use the older VC6 versions of PHP compiled with the legacy Visual Studio 6 compiler. Do NOT use VC9+ versions of PHP with the apache.org binaries.ui

With Apache you have to use the Thread Safe (TS) versions of PHP.spa

VC9, VC11 & VC14

More recent versions of PHP are built with VC9, VC11 or VC14 (Visual Studio 2008, 2012 or 2015 compiler respectively) and include improvements in performance and stability.线程

- The VC9 builds require you to have the Visual C++ Redistributable for Visual Studio 2008 SP1 x86 or x64 installedorm

- The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 x86 or x64 installedserver

- The VC14 builds require to have the Visual C++ Redistributable for Visual Studio 2015 x86 or x64 installed

TS and NTS

TS refers to multithread capable builds. NTS refers to single thread only builds. Use case for TS binaries involves interaction with a multithreaded SAPI and PHP loaded as a module into a web server. For NTS binaries the widespread use case is interaction with a web server through the FastCGI protocol, utilizing no multithreading (but also for example CLI).