Magento:Lighttpd 与 Nginx

发布于 2024-12-18 04:02:14 字数 1432 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墟烟 2024-12-25 04:02:14

你应该抛弃阿帕奇吗?

根据我的经验(使用 Nginx + PHP 大约 3.5 年),这是一个很好的选择,我永远不会回到 Apache。有两个主要优点:

减少内存使用:使用 Apache,PHP 加载在网络服务器本身内部。如果您有 80 个 Apache 进程进行监听,那么每个进程都将运行不同的 PHP 环境,每个进程使用 20-30MB 的 RAM。另一方面,Nginx 与一堆 php-fpm 进程通信,您可以单独扩展这些进程。我通常只需要运行 3-4 个 PHP 进程,因此这大大减少了我的内存使用量。

非常快的静态资源:Nginx 在提供静态资源(CSS、JS、图像等)方面比 Apache 更快,并且只使用很少的内存。

一个可能的缺点是缺乏 .htaccess 文件支持。这意味着,如果您使用的 PHP 软件依赖于此类文件并且不直接提供 Nginx 配置示例,则您必须将 Apache .htaccess 文件“翻译”为以下格式: Nginx 明白。根据我的经验,我必须为几个 Wordpress 插件执行此操作。同样,这并不太复杂,您通常可以通过谷歌搜索找到已经完成此操作的人。

另一件需要记住的事情是,Nginx+PHP-FPM 并不是某种神奇的万能药。如果您的 PHP 代码蹩脚、缓慢,这并不能解决问题。我对 Magento 的经验有限,所以我无法为您提供任何具体的见解。就 WordPress 而言(我认为它非常臃肿),Nginx 在提供静态内容方面确实要快得多,使用更少的内存,并且在提供 PHP 页面方面更快一些,但它肯定不会将 PHP 执行时间减少一半;)

Nginx 与 Lighttpd

Nginx 最近非常受欢迎。去年,它的使用量几乎翻了一番,根据这些统计数据,它的使用量已经是 Lighttpd 的 16 倍

两者之间的性能似乎没有太大差异,所以我肯定会选择 Nginx。

请记住,您必须将 PHP 用作 php-fpm。配置起来并不困难,并且有无数简单的教程介绍如何使它们协同工作。

编辑:抱歉,我重新组织了我的答案,我一开始有点错过了你的问题的要点。

Should you ditch Apache?

In my experience (using Nginx + PHP for about 3.5 years) it's a wonderful choice and I would never go back to Apache. There are two main advantages:

Reduced memory usage: Using Apache, PHP is loaded inside the webserver itself. If you have 80 Apache processes listening, everyone of them will run a different PHP environment, using 20-30MB of RAM each. Nginx, on the other hand, communicates with a bunch of php-fpm processes which you can scale separately. I usually have to run only 3-4 PHP processes, so this drastically reduces my memory usage.

Very fast static assets: Nginx is faster than Apache at serving static assets (CSS, JS, images, ...), and uses very little memory to do so.

One possible drawback is the lack of .htaccess files support. This means that if the PHP software you're using relies on this type of file and doesn't directly offer Nginx configuration examples, you will have to "translate" the Apache .htaccess file to a format that Nginx understands. In my experience, I had to do it for a couple of Wordpress plugins. Again, it's not too complicated and you can usually find someone who has already done it by googling.

The other thing to keep in mind is that Nginx+PHP-FPM is not some kind of magical panacea. If you have crappy, slow PHP code, this won't fix it. I have limited experience with Magento so I cannot offer you any specific insight. In the case of Wordpress (which I consider extremely bloated), Nginx is indeed a lot faster at serving static content, uses less memory and is a bit faster at serving PHP pages, but it certainly doesn't cut your PHP execution time in half ;)

Nginx vs Lighttpd

Nginx has recently gained a lot of popularity. Its usage has almost doubled in the last year and it's already 16 times more used than Lighttpd based on these statistics.

There doesn't seem to be a huge difference in performance between the two, so I would definitely go with Nginx.

Keep in mind that you will have to use PHP as php-fpm. It's not that difficult to configure, and there are countless, easy tutorials on how to make them work together.

Edit: Sorry I re-organized my answer, I kind of missed the point of your question at first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文