> 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本质上是反向代理服务器，需要反向代理就选它
