PHP questions about VC11,VC9,VC6 and the choice of thread safe and non thread safe versions

Source: Internet
Author: User
Tags php source code vc9

Here is the information I collected when building the PHP environment for your reference:

Now PHP official Download PHP installation package has VC11 or VC9 words, what does this mean, we should download which kind of installation package better? In fact, the PHP official website gives the answer:

The VC6 version is compiled with the visual Studio 6 compiler, and if your PHP is built with Apache, you choose the VC6 version. (PHP is no longer VC6 now).

VC9 means that this version of PHP is compiled with VisualStudio2008, and VC11 is compiled with VisualStudio2012. This means that

If you download the VC9 version, you need to VISUALC++REDISTRIBUTABLEFORVISUALSTUDIO2008SP1 first,

If you download the VC11 version, you will need to visualc++redistributableforvisualstudio2012 first.

Build PHP First look at the operating system version, if it is windows here:

is the operating system 32-bit or 64-bit? If it is 32-bit, choose the version with "x86", if it is 64-bit, select the version with "x64". and see what the Web server is? In the case of the IIS family, choose the version with "Non thread safe", and if it is the Apache httpd series, choose the version with "Thread Safe". If it is Apache httpd also see how this binary version is compiled, there are three types of compilation, namely: VC6, VC9, VC11 (respectively, for Visual C + + 6, Visual C + + 2008, Visual C + + 2012). Here is the trouble: PHP official version 5.5 has been compiled with VC11, 5.4 is compiled with VC9. But the latest version of Apache HTTPD is still compiled with VC6. This means an amazing fact: the official version of Apache httpd and the official version of PHP are incompatible! What is the apache+php of the existing Windows? can use VC11 to compile Apache httpd, but this is too frustrating, PHP official recommended to download the third party packaged Apache HTTPD version, recommended this site:, Need to note: This VC11 does not support XP, if you like me have XP nostalgia, the highest can only upgrade to 5.4.24,5.5 is compiled with VC11, and VC11 does not support XP and 2003.

If it's the Linux department, download the PHP source here:

Unlike the above version of Windows, the download here can not be used directly, just PHP source code, to install the need to compile their own, to compile the need to install GCC, make and a bunch of compiled software. See the documentation that says./configure, make, make install, for the PHP version of the source.

Compiling PHP yourself is even more troublesome, relying on a lot of libraries, waiting for people to fall into the pits also have a lot, I will say in another article. If you have trouble, you can find the compiled version, specifically the distribution of the official software library. The following is a popular Ubuntu and CentOS department as an example of the separate description;

Deb Package Management (Ubuntu, Debian)

With Apt-cache search PHP command can search a lot of results, we need to be "php5", The complete command is: Apt-get install PHP5

This is obviously not always applicable, because there is a version number 5 in the command, and the future of PHP6 is not known.

If you want to install a command-line PHP engine in the shell, install this package

Apt-getinstall PHP5-CLI

RPM Package Management (Fedora, RedHat, SUSE, CentOS)

Yuminstall PHP

If it is a PHP command line, install Yuminstall PHP-CLI

How do I choose the thread safe and non threadsafe version?

The Windows version of PHP from version 5.2.1 started with Threadsafe (thread-safe) and none thread safe (NTS, non-thread-safe) of the points, which is the difference between? Which one should I use? Here is a simple introduction.

The first Windows version of PHP3.0.17, released on October 20, 2000, started with a thread-safe version, because unlike the Linux/unix system, which works in a multi-process manner, Windows systems work in a multi-threaded way. It is very slow to run PHP as CGI under IIS, because the CGI pattern is built on a multi-process basis, not multithreaded. In general, we will configure PHP to run in ISAPI way, ISAPI is multi-threaded way, so much faster. There is a problem, however, that many commonly used PHP extensions are developed with Linux/unix's multi-process thinking, which can be faulted when running in ISAPI mode. Therefore, the CGI mode under IIS is the safest way to run PHP, but the CGI mode requires reloading and uninstalling the entire PHP environment for each HTTP request, which consumes a huge amount.

To take into account the efficiency and security of PHP under IIS, Microsoft has given the fastcgi solution. FastCGI can allow the PHP process to be reused instead of every new request to re-open a process. FastCGI can also allow several processes to execute simultaneously. This solves the problem that the CGI process pattern consumes too much, and the CGI process pattern does not have the advantage of the thread security problem.

In the first place, it is a thread safe to understand the literal meaning that thread security is performed in order to prevent the new requirements from exhausting system resources by starting the CGI execution of new threads. Non thread safe is non-threaded and does not thread (thread) security checks at execution time.

Therefore, if you are using ISAPI to run PHP must use Threadsafe (thread-safe) version, while running PHP in fastcgi mode, there is no need to use thread security, with none thread safe (NTS, non-thread-safe) Version to better improve efficiency.

Let's look at two ways of executing PHP: ISAPI and fastcgi.

ISAPI execution mode is used in the form of DLL dynamic library, can be executed after the user request, after processing a user request will not disappear immediately, so the need for thread security check, so as to improve the execution efficiency of the program, so if it is to execute PHP with ISAPI, it is recommended to choose thread Safe version;

The fastcgi execution is performed with a single thread, so there is no need for thread security checks, and the removal of thread safety checks can improve execution efficiency, so if PHP is executed in fastcgi, it is recommended to choose the non thread safe version.

The above describes the PHP vc11,vc9,vc6 and the thread safe and non thread safe version of the issue, including the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.