线程安全和非线程安全 PHP Windows 安装包之间的技术区别是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5793751/
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
What are the technical differences between the Thread Safe and Non Thread safe PHP Windows Installation Packages?
提问by Chuck Le Butt
I'm currently about to install PHP for an Apache/Windows-based development environment, but it seems I'm about to fall at the first hurdle: Choosing the right package to install.
我目前正准备为基于 Apache/Windows 的开发环境安装 PHP,但似乎我即将遇到第一个障碍:选择要安装的正确软件包。
PHP is available in no less than fourflavours:
- VC9 x86 Non Thread Safe
- VC9 x86 Thread Safe
- VC6 x86 Non Thread Safe
- VC6 x86 Thread Safe
- VC9 x86 非线程安全
- VC9 x86 线程安全
- VC6 x86 非线程安全
- VC6 x86 线程安全
What's the difference between these versions in a practicalsense?
这些版本在实际意义上有什么区别?
If this wasn't complicated enough, version 5.3 of PHP is only available in VC9 (with 5.2 coming with the VC6 packages). And yet, according to the PHP site, you should notuse VC9 with Apache... So why does Apache get the older version?
如果这还不够复杂,PHP 5.3 版仅在 VC9 中可用(5.2 版随 VC6 包一起提供)。然而,根据PHP的网站,你应该不使用VC9与Apache ...那么,为什么阿帕奇获得旧版本?
It's all very confusing and I'd like some help understanding the choices.
这一切都非常令人困惑,我需要一些帮助来理解这些选择。
回答by Chuck Le Butt
After a lot of research, I've managed to find my own answers to this question.
经过大量研究,我设法找到了自己对这个问题的答案。
In its most basic form, the answer is: What version of PHP you should install comes down what webserver you are running.
在最基本的形式中,答案是:您应该安装哪个版本的 PHP 取决于您正在运行的网络服务器。
Here's a deeper explanation of the terms used in picking a version of PHP based on what I learned:
以下是根据我所了解的选择 PHP 版本时使用的术语的更深入解释:
VC6 vs VC9
VC6 与 VC9
Firstly, different versions of Apache for Windows are compiled with different compilers. For example, the versions on Apache.orgare designed to be compiled using Microsoft Visual C++ 6, also known as VC6. This compiler is very popular, but also very old. (It dates back to 1998.)
首先,不同版本的 Apache for Windows 使用不同的编译器进行编译。例如,Apache.org上的版本旨在使用Microsoft Visual C++ 6编译,也称为VC6。这个编译器很流行,但也很老了。(它可以追溯到 1998 年。)
There are different versions of Apache made for different compilers. For example, the versions available for download from ApacheLounge.comare designed to be compiled with the popular and more much recent compiler, Microsoft Visual C++ 9from 2008. Also known as VC9.
有为不同的编译器制作的不同版本的 Apache。例如,可从ApacheLounge.com下载的版本被设计为使用流行的和更新的编译器编译,即2008 年的Microsoft Visual C++ 9。也称为VC9。
(Note: These two compilers are the two most popular options. So while it's possible to have a VC7, VC8, etc. compiled version of Apache, it's unlikely that you'll come across them.)
(注意:这两个编译器是最流行的两个选项。因此,虽然可能有 VC7、VC8 等编译版本的 Apache,但您不太可能遇到它们。)
The use of this more recent compiler (VC9) is important because the latest versions of PHP are only being distributed in VC9 form (although older versions are still available for VC6).
使用这个更新的编译器 (VC9) 很重要,因为最新版本的 PHP 仅以 VC9 形式分发(尽管旧版本仍可用于 VC6)。
On top of that, according to ApacheLounge there are numerous improvements when using a version of Apache compiled with VC9, "in areas like Performance, MemoryManagement and Stability".
最重要的是,根据 ApacheLounge 的说法,在使用使用 VC9 编译的 Apache 版本时,“在性能、内存管理和稳定性等方面”有许多改进。
If that wasn't enough, the developers of PHP made the following statement on their site:
如果这还不够,PHP 的开发人员在他们的网站上发表了以下声明:
Windows users: please mind that we do no longer provide builds created with Visual Studio C++ 6 (VC6). It is impossible to maintain a high quality and safe build of PHP for Windows using this unmaintained compiler.
We recommend the VC9 Apache builds as provided by ApacheLounge.
All PHP users should note that the PHP 5.2 series is NOT supported anymore. All users are strongly encouraged to upgrade to PHP 5.3.6.
Windows 用户:请注意,我们不再提供使用 Visual Studio C++ 6 (VC6) 创建的构建。使用这种未维护的编译器,不可能为 Windows 维护高质量和安全的 PHP 构建。
我们推荐 ApacheLounge 提供的 VC9 Apache 构建。
所有 PHP 用户都应该注意,不再支持 PHP 5.2 系列。强烈建议所有用户升级到 PHP 5.3.6。
In all, this is an extremely compelling argument to use VC9 versions of Apache and PHP, if you ask me.
总之,如果你问我,这是使用 Apache 和 PHP 的 VC9 版本的一个非常有说服力的论据。
So if you're using a version of Apache from the official Apache site, it will be compiled with VC6, and as such, you should use the older version of PHP for that compiler. If you're using a version of Apache compiled with VC9, like the one available on ApacheLounge.com, you can use the latest version of PHP (for VC9).
因此,如果您使用来自官方 Apache 站点的 Apache 版本,它将使用 VC6 编译,因此,您应该为该编译器使用旧版本的 PHP。如果您使用的是用 VC9 编译的 Apache 版本,例如ApacheLounge.com 上提供的版本,则可以使用最新版本的 PHP(用于 VC9)。
For me, running a local development environment, it would be preferable to have the latest version of PHP, so a VC9 version of Apache is required, so I can use the VC9 version of PHP.
对我来说,运行本地开发环境,最好有最新版本的PHP,所以需要VC9版本的Apache,这样我就可以使用VC9版本的PHP了。
Thread Safe vs Non Thread Safe
线程安全与非线程安全
Once again this comes down to your webserver. By default Apache is installed on Windows as Module, but it can be changed to run as FastCGI. There's plenty of differences between the two, but essentially FastCGI is more modern, faster, more robust, and more resource hungry. For someone running a local development environment, FastCGI might be overkill, but apparently lots of hosting companies run as FastCGI for the reasons I've stated, so there are good arguments for doing so in a development environment.
这再次归结为您的网络服务器。默认情况下,Apache 作为模块安装在 Windows 上,但可以更改为作为FastCGI运行。两者之间有很多差异,但从本质上讲,FastCGI 更现代、更快、更健壮,并且更需要资源。对于运行本地开发环境的人来说,FastCGI 可能有点矫枉过正,但显然许多托管公司出于我所说的原因运行 FastCGI,因此在开发环境中这样做是有充分理由的。
If you're running Apache (or IIS) as FastCGI (or CGI) then you want the Non Thread Safeversion of PHP. If you're running Apache as default (as a Module), then you'll want the more traditional Thread Safeversion.
如果您将 Apache(或 IIS)作为 FastCGI(或 CGI)运行,那么您需要PHP的非线程安全版本。如果您默认运行 Apache(作为模块),那么您将需要更传统的线程安全版本。
Please note: This all only applies to Windows users.
请注意:这一切仅适用于 Windows 用户。
I'm not going to bother with FastCGI (unless someone convinces me otherwise), so for me, I want the VC9 Thread Safe version of PHP.
我不会打扰 FastCGI(除非有人说服我否则),所以对我来说,我想要PHP的VC9 线程安全版本。
And that's it.
就是这样。
Further reading:
进一步阅读:
回答by Dan Blows
Personally, I use a virtualised LAMP server. Every hosting service I use is on some flavour of Linux, and there are too many differences between WAMP and LAMP. Then I just use the default tasksel LAMP server for that version of Linux.
就个人而言,我使用虚拟化 LAMP 服务器。我使用的每个托管服务都使用某种风格的 Linux,WAMP 和 LAMP 之间存在太多差异。然后我只为那个版本的 Linux 使用默认的 tasksel LAMP 服务器。
My actual setup right now is with VMWare (Fusion on Mac, Player on Windows). I have 3 VMs - one for PHP5.3 with Ubuntu 10.04 LTS, and another for PHP 5.1 on Ubuntu 8.04 LTS. (One of the hosts I use is on RedHat, which currently supports only PHP 5.1). I have a third VM for RubyOnRails dev.
我现在的实际设置是使用 VMWare(Mac 上的 Fusion,Windows 上的 Player)。我有 3 个虚拟机 - 一个用于 Ubuntu 10.04 LTS 上的 PHP5.3,另一个用于 Ubuntu 8.04 LTS 上的 PHP 5.1。(我使用的主机之一是 RedHat,目前仅支持 PHP 5.1)。我有第三个用于 RubyOnRails 开发的虚拟机。
In other words, I try to get my development environment as close to my production environment as possible. So work out what version of Apache and PHP is on your host, and use that as your guide.
换句话说,我尝试让我的开发环境尽可能接近我的生产环境。因此,确定您的主机上的 Apache 和 PHP 版本,并将其用作您的指南。