> For the complete documentation index, see [llms.txt](https://phper.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://phper.shujuwajue.com/phpxuan-xiang-he-yun-xing-yuan-li/apache-yu-nginx.md).

# Apache 与 Nginx

## 为什么大访问量下Nginx性能更高？

* Apache所采用的select网络I/O模型非常低效
* Nginx使用了最新的epoll（Linux 2.6内核）和kqueue（freebsd）网络I/O模型

> Apache进程干的事情多：执行PHP、输出HTML都得干，占用的资源就多（CPU、内存）

## 比较I/O模型select和epoll

![](/files/-LfnTHbT48NeUKAR3JYg)

## 如何选择 Apache 与 Nginx？

* 一般访问量网站优先选择Apache，它稳定可靠
* Apache模块非常丰富，为了用它的模块得选它
* Apache的rewrite非常强大，rewrite多就选择它
* 大访问量优先选择Nginx，它支持更多的并发连接
* 处理的都是静态内容（html，图片），首选Nginx
* Nginx本质上是反向代理服务器，需要反向代理就选它


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://phper.shujuwajue.com/phpxuan-xiang-he-yun-xing-yuan-li/apache-yu-nginx.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
