在 Windows/IIS 7 与 Linux/Apache 下运行 PHP 的性能差异?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/798896/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 17:31:44  来源:igfitidea点击:

Performance differences running PHP under Windows/IIS 7 vs. Linux/Apache?

phpperformanceapacheiis

提问by cdeszaq

There is a PHP application right now on a Linux box running under Apache with MySQL. Since we are a windows shop, management wants to get rid of the Linux box and move everything over to windows. Is there a performance difference between the two platforms? Or, is there any significant difference at all, in terms of performance or management?

现在有一个 PHP 应用程序在运行在带有 MySQL 的 Apache 下的 Linux 机器上。由于我们是一家 windows 商店,管理层希望摆脱 Linux 盒子,将所有东西都转移到 windows 上。两个平台之间有性能差异吗?或者,在绩效或管理方面是否有任何显着差异?

采纳答案by troelskn

Microsoft had a team help out optimising PHP for Windows, which work is part of PHP 5.3. Some figures I've seen places the performance close to PHP + Apache on a unix system. Before 5.3 (Which means currently, since 5.3 isn't out yet), performance is bad on Windows. I think there are some patches and tricks you can pull to improve it, but it's going to cost you a bit of performance. That may or may not be a problem; People have a tendency to overestimate performance.

Microsoft 有一个团队帮助为 Windows 优化 PHP,该工作是 PHP 5.3 的一部分。我所看到的一些数据表明,Unix 系统上的性能接近 PHP + Apache。在 5.3 之前(这意味着目前,因为 5.3 尚未发布),Windows 上的性能很差。我认为您可以使用一些补丁和技巧来改进它,但这会降低您的性能。这可能是也可能不是问题;人们有高估绩效的倾向。

Note that there are other reasons to use unix than just performance. Code may not be portable and even though the core php runs fairly ok, you can well get into trouble with php-extensions and third party libraries. No matter how you look at it, Windows is a second-rate system for running php on.

请注意,除了性能之外,还有其他使用 unix 的原因。代码可能不可移植,即使核心 php 运行得相当好,您也可能会遇到 php 扩展和第三方库的麻烦。不管你怎么看,Windows 都是运行 php 的二流系统。

回答by Javier Constanzo

If your application isn't huge or get hit a couple thousand times per second, there's no difference between the two. LAMP == WAMP in php small projects. Just install something like XAMPPif you want your environment to be as close as possible to your existing one but in Windows.

如果您的应用程序不是很大,或者每秒被点击几千次,那么两者之间没有区别。LAMP == WAMP 在 php 小项目中。如果您希望您的环境尽可能接近您现有的但在 Windows 中的环境,只需安装类似XAMPP 的东西。

Good luck with your project!

祝你的项目好运!

回答by Javier Constanzo

You should consider the MS WebPI (download at www.microsoft.com/web ) which would install the entire stack for you to run PHP in IIS7 environment.

您应该考虑 MS WebPI(从 www.microsoft.com/web 下载),它将安装整个堆栈,以便您在 IIS7 环境中运行 PHP。

the performance is comparable for most apps.

性能与大多数应用程序相当。

回答by Javier Constanzo

I've just done this for the same reason. Mgt wanted to get rid of the Linux box. I was able to completely move my php application and MySQL database. It took longer for me to configure PHP for IIS than it did for me to move the existing content over. I have found though that the IIS server is a fair bit slower when it comes to loading pages and images. Where in Linux it appeared instantaneous, in IIS it takes a half second for the page to load and another second for images.

出于同样的原因,我刚刚这样做了。Mgt 想要摆脱 Linux 盒子。我能够完全移动我的 php 应用程序和 MySQL 数据库。我为 IIS 配置 PHP 花费的时间比我移动现有内容所花费的时间更长。我发现 IIS 服务器在加载页面和图像时要慢一些。在 Linux 中它是即时出现的,而在 IIS 中,页面加载需要半秒,图像需要另一秒。