Introduction to nginx apache

1. Introduction to the server

1、apache

           Apache is the number one server in the world. According to statistics, more than 50% of web servers in the world are using apache.

Features of apache:

1) Can run on almost all computer platforms.

2) Support the latest http/1.1 protocol

3) Simple and powerful file-based configuration (httpd.conf).

4) Support Common Gateway Interface (cgi)

5) Support virtual host.

6) Support http authentication.

7) Integrate perl.

8) Integrated proxy server

9) The status of the server can be monitored through a web browser, and the log can be customized.

10) Support server-side include commands (ssi).

11) Support secure socket layer (ssl).

12) It has the ability to track user session process.

13) Support fastcgi

14) Support java servlets

2、nginx

 

          1. Nginx is a very lightweight HTTP server written by Russians. Nginx, its pronunciation is "engineX", is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server. Nginx was developed by Russian Igor Sysoev for the second most visited Rambler.ru site in Russia.

2. As an HTTP server, nginx has the following basic features:

Process static files, index files, and automatic indexing; open file descriptor buffering.

Cacheless reverse proxy acceleration, simple load balancing and fault tolerance.

FastCGI, simple load balancing and fault tolerance.

Modular structure.

Nginx has high stability.

Nginx supports hot deployment




First, the difference between apache and nginx:

        1. The core difference between the two is that apache is a synchronous multi-process model, one connection corresponds to one process; nginx is asynchronous, and multiple connections (ten thousand levels) can correspond to one process. Nginx handles static files well and consumes less memory. But undoubtedly apache is still the mainstream, with many rich features. So it needs to be matched. Of course, if you can determine that nginx is suitable for your needs, then using nginx will be a more economical way .

        2、nginx的负载能力比apache高很多。最新的服务器也改用nginx了。而且nginx改完配置能-t测试一下配置有没 有问题。

        3、apache重启的时候发现配置出错了,会很崩溃,改的时候都会非常小心翼翼现在看有好多集群站,前端nginx抗并发,后端apache集群, 配合的也不错。

        4、nginx处理动态请求是鸡肋,一般动态请求要apache去做,nginx只适合静态和反向。

        5、从经验来看,nginx是很不错的前端服务器,负载性能很好,nginx,用webbench模拟10000个静态文件请求毫不吃力。 apache对php等语言的支持很好,此外apache有强大的支持网络,发展时间相对nginx更久,bug少但是apache有先天不支持多核心处理负载鸡肋的缺点,建议使用nginx做前端,后端用apache。大型网站建议用nginx自代的集群功能。

       6、大部分情况下nginx都优于APACHE,比如说静态文件处理、PHP-CGI的支持、反向代理功能、前端 Cache、维持连接等等。在Apache+PHP(prefork)模式下,如果PHP处理慢或者前端压力很大的情况下,很容易出现Apache进程数 飙升,从而拒绝服务的现象。

        7、Apache在处理动态有优势,Nginx并发性比较好,CPU内存占用低,如果rewrite频繁,那还是Apache吧!

        8、一般来说,需要性能的web 服务,用nginx 。如果不需要性能只求稳定,那就apache 吧。
二、apache与nginx优缺点比较

1、nginx相对于apache的优点: 
       轻量级,同样web 服务,比apache 占用更少的内存及资源
抗并发,nginx 处理请求是异步非阻塞的,而apache 则是阻塞型的,在高并发下nginx 能保持低资源低消耗高性能 ;
       高度模块化的设计,编写模块相对简单 ;
       社区活跃,各种高性能模块出品迅速啊 ;
      Nginx本身就是一个反向代理服务器 ,Nginx支持7层负载均衡;Nginx可能会比apache支持更高的并发,
      nginx配置文件写的很简洁,正则配置让很多事情变得简单运行效率高,占用资源少,代理功能强大,很适合做前端响应服务器 !
2、apache 相对于nginx 的优点: 
rewrite ,比nginx 的rewrite 强大 ;
       模块超多,基本想到的都可以找到 ;
       少bug ,nginx 的bug 相对较多 ;
       超稳定 ,Aapche依然是大部分公司的首先,因为其成熟的技术和开发社区已经 也是非常不错的性能。
  三、为什么现在 Nginx 才是 Web 服务器的首选 
       Nginx 是一个安装非常的简单 , 配置文件非常简洁(还能够支持perl语法), Bugs 非常少的服务器: Nginx 启动特别容易, 并且几乎可以做到7*24不间断运行,即使运行数个月也不需要重新启动. 你还能够不间断服务的情况下进行软件版本的升级 . 

         Nginx 配置简洁, Apache 复杂 , Nginx 静态处理性能比 Apache 高 3倍以上 , Apache 对 PHP 支持比较简单,Nginx 需要配合其他后端用,   Apache 的组件比 Nginx 多 。     

现在 Nginx 才是 Web 服务器的首选 ,也可二者混合使用。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325715530&siteId=291194637