Nginx 和 Apache 有什么区别?

发布于 2024-11-05 20:12:29 字数 336 浏览 0 评论 0原文

我不太明白 Nginx 和 Apache 有什么区别?

我想使用 PHP Comet 技术进行聊天。我确实喜欢这样:

while($modification_date == filemtime($filename)) { 
    sleep(2); 
}

//$filename was updated and we retrieve new messages and give them to the user with JSON help

它当然在 Apache 中不起作用。它能在 Nginx 中工作吗?

请不要向我提供 NodeJS 和其他内容。

I don't quite get what is the difference between Nginx and Apache?

I want to use PHP Comet technique for the chat. I do like that:

while($modification_date == filemtime($filename)) { 
    sleep(2); 
}

//$filename was updated and we retrieve new messages and give them to the user with JSON help

It of course doesn't work in Apache. Will it work in Nginx?

Do not offer me NodeJS and other, please.

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

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

发布评论

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

评论(2

梦里南柯 2024-11-12 20:12:29

Apache 和 Nginx 之间的主要区别是一个是线程驱动的,另一个是事件驱动的。但是,我认为你的问题不清楚。它们与您的代码片段无关。首先解释一下为什么它在 Apache 中不起作用。

Main difference between Apache and Nginx is one is thread driven and another is event driven. But, I think your question is not clear. They have nothing to do with your code snippet. And first explain why It'll not work in Apache.

何时共饮酒 2024-11-12 20:12:29

Nginx 不会自动使该代码工作。它会像在 Apache 中一样糟糕。主要问题是 PHP 不是线程安全的,每个请求都需要一个分叉的 PHP 过程来处理该请求。这意味着需要大量的 RAM 才能扩展到任何合适的大小。 Nginx 可以通过不同的编程风格(comet)和扩展的帮助来解决这个问题

Nginx doesn't automagically make that code work. It will suck equally as bad as it did in Apache. The main problem is that PHP isn't threadsafe and each request needs one forked PHP proc to handle the request. This translates into insanely large amounts of needed RAM to scale to anything of decent size. Nginx can get around this problem by a different style of programming (comet) and the help of an extension.

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