Originally from: http://www.ituring.com.cn/article/128439
The PHP development environment under Windows builds--php thread-safe and non-threaded security, Apache version selection, and detailed five modes of operation.
Today, in order to build a PHP development environment under Windows, when considering what version of PHP to download, encounter some confusing situations, to solve these puzzles, not surprisingly involved more confusing problems.
In order to clean sweep these puzzles, I spent an afternoon and a night looking through a lot of information, and after doing some experiments, I finally put all these confusion clearly.
To tell the truth, the reason for spending so much time, largely because the online information is almost all fragmented, baseless assertion. Now that I understand it, I take the time to sort it out, that is, it is convenient for you to look at and easy to read. This article, I believe, can answer many of the confusion of friends who build PHP development environment under Windows.
about where to download Apache:
To install Apache, you may take it for granted that you will download a binary version of Windows for the official Apache website. And that's just wrong!
PHP is not officially recommended to install Apache binary installation packages downloaded from the apache.org website under Windows. The reason is that if you're using an installation package from apache.org, because these packages are compiled based on outdated visual Studio 6, you have to have to use the same old version of PHP (that is, the PHP version of VC6). This is also the version of PHP compiled with Visual Studio 6) in order to work with it.
To use the latest version of PHP, you should follow the official PHP recommendations. The official PHP recommendation is that you can use IIS under Windows, or use the Apache version from the Apache Lounge (www.apachelounge.com).
The Apache binary installation package provided by the Apache Lounge is built using VC11. So it can be used with the latest version of PHP.
There is a lot of information on the Web that if you are using Apache under Windows, you must use PHP's VC6 version, only use IIS to use VC9 and above, is completely unclear baseless assertion.
How to choose the PHP version (choose Thread-safe or non-thread safe):
Installing PHP under Windows is a great choice for PHP versions.
There are two versions of PHP under Windows: The thread-safe version and the non-thread-safe version.
If you plan to use IIS, you can install PHP in either ISAPI or FASTCGI. The CGI approach is not considered because it is inefficient.
If you want to use PHP in fastcgi mode in IIS, you should use a non-thread-safe version of PHP (Non-thread safe,nts). The reason is that when PHP is installed in fastcgi, PHP has a separate process, and the fastcgi is a single thread, and there is no mutual interference that can arise between multiple threads (usually caused by global variables and static variables). Because of the absence of thread-safe checking, the use of the FastCGI method is more efficient than the ISAPI approach.
If you want to use PHP in an ISAPI manner in IIS, you should use the thread-safe version of PHP (thread safe,ts). The reason is that when PHP is installed in ISAPI mode, PHP does not have a separate process, but is loaded as a DLL by IIS, which is attached to the Web server process. When the Web server is running in multithreaded mode (this is the case with IIS), PHP naturally runs in multithreaded mode. As long as you are running in multithreaded mode, there may be a thread safety issue, so you should choose a thread-safe version of PHP.
But here it is necessary to explain, although Apache itself is thread-safe, and you also choose the thread-safe version of PHP, but because some of the third-party extensions under Apache and PHP were originally developed based on the multi-process of Unix, in the design and development without regard to the issue of thread safety, Therefore, it is not ruled out that in this case there is still the possibility of IIS being crashed by some third-party extensions.
If you plan to use Apache, you can install PHP in three ways, such as modules, ISAPI, fastcgi. The CGI approach is not considered because it is inefficient.
If you want to install PHP as a module in Apache, you should use a thread-safe version of PHP. The reason is that when PHP is installed as an Apache module, PHP does not have a separate process, but as a module in the form of a DLL loaded into Apache, is launched with the Apache boot, and Windows Apache is multithreaded mode of operation, So PHP naturally runs in multithreaded mode as well. Therefore, the thread-safe version of PHP should be used in this case.
Look at the ISAPI situation again. ISAPI is generally considered to be used with IIS because the ISAPI was originally developed by Microsoft for IIS. But Apache can now also implement the ISAPI functionality by loading the mod_isapi.so module to allow PHP to be installed in an ISAPI manner. The so file is a module naming convention that has been developed by Apache since version 1.3 for Windows, and for Apache under Windows,. So is a dynamic-link library file, as is the. dll file.
When you want to install PHP in an ISAPI fashion, you typically load a DLL file named PhpXisapi.dll, where X is Arabic numerals 4, 5, and so on.
However, it is generally not recommended to install PHP in Apache as an ISAPI, because so far, the ISAPI functionality implemented by Apache through the Mod_isapi.so module is incomplete and does not fully implement all the specifications Microsoft has set for ISAPI.
Similarly, PHP does not have a separate process for installing PHP as an ISAPI, and it is also loaded into Apache as a module, so it is also necessary to use the thread-safe version of PHP.
If you are using PHP in fastcgi mode in Apache, you should use PHP's non-thread-safe version as in the case of PHP with fastcgi in IIS. The reason is that when PHP is installed in Apache in fastcgi mode, PHP has a separate process and fastcgi is a single thread, so you should use a non-threaded version of PHP to improve performance.
Go: The PHP development environment under Windows builds--php thread-safe and non-threaded security, Apache version selection, and detailed five modes of operation.