apache nginx

Apache and NGINX are the two most popular and open source web servers used all over the world and controls over 60% of the market share. Although the functionalities of both of them are pretty same, they differ in terms of their architecture, performance, and security along with a few other key points.

Apache和NGINX是在世界范围内使用的两种最受欢迎​​的开源Web服务器,它们控制着60%以上的市场份额。 尽管它们的功能非常相似,但是它们在体系结构,性能和安全性以及其他一些关键点方面有所不同。

However, choosing one of them as a web server is not always easy since both of them are exceptionally well with a great track record.

但是,选择其中一个作为Web服务器并不总是一件容易的事,因为他们两个都拥有出色的业绩,而且表现特别出色。

NGINX与Apache (NGINX vs Apache)

Nginx Vs Apache

Nginx Vs Apache

Nginx与Apache

In this article, we will discuss a few key differences between Apache and NGINX to help you select either of them that suits your requirements.

在本文中,我们将讨论Apache和NGINX之间的一些关键区别,以帮助您选择适合您需求的两者。

1.表现 (1. Performance)

Both Apache and NGINX serves static and dynamic content differently. Apache uses a traditional file-based method for serving static content like CSS, JS or image file. However NGINX offers lot of options to optimize performances for serving static content.

Apache和NGINX均以不同方式提供静态和动态内容。 Apache使用传统的基于文件的方法来提供静态内容,例如CSS,JS或图像文件。 但是,NGINX提供了许多选项来优化性能以提供静态内容。

NGINX is better placed at serving static content or media under extreme load. According to some benchmark report, NGINX is 2 times faster than Apache while serving static content.

NGINX更适合在极端负载下提供静态内容或媒体。 根据一些基准测试报告,NGINX在提供静态内容时比Apache快2倍。

In case of processing dynamic content like PHP pages, both of them forwards the request to separate environment for PHP. While Apache is directly involved with processing PHP pages but Nginx uses the services of php-fpm to do the same.

在处理动态内容(例如PHP页面)的情况下,它们都将请求转发到单独PHP环境。 虽然Apache直接参与处理PHP页面,但是Nginx使用php-fpm的服务来完成相同的工作。

NGINX if configured properly with PHP-FPM, can process dynamic content quite efficiently. Apache is also equally efficient in processing PHP pages when multi-processing event modules (mpm_event) is configured correctly with PHP-FPM.

如果使用PHP-FPM正确配置了NGINX,则可以非常有效地处理动态内容。 当使用PHP-FPM正确配置了多处理事件模块(mpm_event)时,Apache在处理PHP页面方面同样有效。

Therefore in case of serving dynamic content, both Apache and NGINX are equally good.

因此,在提供动态内容的情况下,Apache和NGINX都同样出色。

2.建筑 (2. Architecture)

The design architecture of Apache and NGINX are quite different and it affects the way they handle connections and traffic from clients. Apache is based on the process-driven architecture where it creates a new thread for each connection request. This lead to heavy resource usages during heavy traffic that can cause issues with Apache.

Apache和NGINX的设计架构完全不同,它影响了它们处理来自客户端的连接和流量的方式。 Apache基于进程驱动的体系结构,在该体系结构中,Apache为每个连接请求创建一个新线程。 这会导致在繁忙的流量中占用大量资源,从而可能导致Apache问题。

On the other hand, NGINX employs non-blocking event-driven architecture and can serve thousands of concurrent requests with a single thread. In NGINX, a single master process (per CPU) creates multiple worker processes and each worker process has only one thread. As a result, NGINX works very efficiently with limited resources. This is in contrast to Apache where it can handle only one connection with a single thread.

另一方面,NGINX采用非阻塞事件驱动的体系结构,可以通过单个线程处理数千个并发请求。 在NGINX中,单个主进程(每个CPU)创建多个工作进程,每个工作进程只有一个线程。 结果,NGINX在有限的资源下非常有效地工作。 这与Apache相反,后者只能通过一个线程处理一个连接。

3.安全性 (3. Security)

When comparing NGINX and Apache in terms of security, Both Apache and NGINX perform exceptionally well with a proven security track record. The mod_evasive and mod_security module of Apache provides an additional layer of security by mitigating DDoS/Brute force attacks and installing a web application firewall respectively.

在安全性方面比较NGINX和Apache时,Apache和NGINX在具有良好安全记录的情况下均表现出色。 Apache的mod_evasive和mod_security模块通过减轻DDoS /暴力攻击并分别安装Web应用程序防火墙来提供附加的安全层。

The Apache Software Foundation follows a proactive policy while dealing with security issues and denial of service attacks against the Apache HTTP server. The foundation also publish security bulletin and encourage users to report any new security issues with Apache.

Apache Software Foundation在处理安全问题和针对Apache HTTP服务器的拒绝服务攻击时遵循主动策略。 该基金会还发布安全公告,并鼓励用户报告Apache的任何新安全问题。

Like Apache, NGINX also list security updates in its site and advises users to follow few recommended configuration settings to mitigate DDoS attacks.

与Apache一样,NGINX也在其站点中列出了安全更新 ,并建议用户遵循一些建议的配置设置来缓解DDoS攻击。

4.模块 (4. Modules)

Both Apache and NGINX can be extended with modules but the way in which functionalities are incorporated using modules are different. There are about 60 modules supported by Apache officially those can be dynamically loaded or unloaded as per your requirements.

Apache和NGINX都可以使用模块进行扩展,但是使用模块合并功能的方式不同。 Apache正式支持大约60个模块,可以根据您的要求动态地加载或卸载这些模块。

NGINX also supports the notion of the module but earlier it was not possible to load modules dynamically into it. The system admins used to compile modules to integrate it to the core. However, in the beginning of 2016 NGINX got the support for dynamic module loading. With dynamic modules, you can optionally load separate shared object files at runtime as modules – both third-party modules and some native NGINX modules.

NGINX也支持模块的概念,但是较早的时候不可能将模块动态加载到模块中。 系统管理员习惯于编译模块以将其集成到核心中。 但是,在2016年初,NGINX获得了对动态模块加载的支持。 使用动态模块,您可以选择在运行时将单独的共享库文件作为模块加载-第三方模块和某些本机NGINX模块。

5.操作系统 (5. Operating System)

Apache supports all major Linux and Non-Linux operating system and works on them perfectly. NGINX also supports Linux and Unix-like operating system but its support to Windows is partial. The performance of NGINX in Widows is also not as robust as compared with Linux.

Apache支持所有主要的Linux和Non-Linux操作系统,并且可以完美地在它们上运行。 NGINX还支持Linux和类似Unix的操作系统,但对Windows的支持是部分的。 NGINX在Widows中的性能也不如Linux强大。

6.支持 (6. Support)

NGINX provides official support for its commercial version NGINX Plus. The commercial version includes few added features in the area of load-balancing, media streaming, and monitoring. For free edition, NGINX offers community support through mailing lists, IRC, and forums.

NGINX为其商业版本NGINX Plus提供官方支持。 商业版本在负载平衡,媒体流和监视领域中几乎没有添加任何功能。 对于免费版本,NGINX通过邮件列表,IRC和论坛提供社区支持。

While Apache does not have any commercial version but all commercial support can be availed through third parties. Like NGINX, Apache also offers community support through mailing lists, IRC and forums.

虽然Apache没有任何商业版本,但是可以通过第三方获得所有商业支持。 与NGINX一样,Apache也通过邮件列表,IRC和论坛提供社区支持。

摘要 (Summary)

In general, Both Apache and NGINX excel in their own areas and cannot be replaced by each other. They have their own strengths and weaknesses. In the end, all depends upon defining exact requirements while choosing either Apache or NGINX.

通常,Apache和NGINX都在各自的领域中表现出色,不能相互替代。 他们有自己的优点和缺点。 最后,一切都取决于在选择Apache或NGINX时定义确切的要求。

According to Google Trends, NGINX is gained a lot of popularity over Apache in the last 5 years and its market share will cross Apache in the next few years for sure.

根据Google趋势,在过去的5年中,NGINX在Apache之上获得了广泛的欢迎,其市场份额肯定会在未来几年内超过Apache。

Google Trends Nginx Apache

Google Trends – Nginx and Apache

Google趋势-Nginx和Apache

Below table gives you a quick overview when comparing NGINX vs Apache web server.

下表提供了NGINX与Apache Web服务器比较时的快速概述。

AreaNGINXApacheWhich is Better?
ArchitectureNon-Blocking Event Driven, requires less CPU and memory.Process driven, create threads for every request, requires more CPU and memory.NGINX
Serving Static ContentNGINX has a lot of options to optimize itApache uses simple file based approachNGINX
Serving Dynamic PHP ContentNGINX uses php-fpm to process PHP pagesApache can process PHP and we can use mpm_event with php-fpm too.Both are equally good.
Resource FootprintNGINX works great with multi-processor environment and uses memory efficiently.Apache requires more memory and CPU in high work load.NGINX
SecurityNGINX configurations are useful to prevent DDoS attacksApache has mod_evasive and mod_security modulesBoth are equally good.
Modules supportNGINX now supports dynamic loading of modulesApache supports a lot of modules that can be dynamically loaded and unloadedBoth are equally good.
Operating System SupportNGINX is great for Unix/Linux systems. However, Windows support is limited.Apache supports all Unix, Linux, Windows OS.If Windows, Apache is better. For others, both are good.
SupportNGINX provides paid support. There is a lot of free community-driven support too.Apache doesn’t have commercial support. However, community support is more than enough to help you.For larger enterprise, NGINX is better as they can get official support. For everybody else, both of them have enough documentation and online resources to cover all your needs.
NGINX 阿帕奇 哪个更好?
建筑 非阻塞事件驱动,需要较少的CPU和内存。 进程驱动,为每个请求创建线程,需要更多的CPU和内存。 NGINX
提供静态内容 NGINX有很多优化它的选项 Apache使用基于简单文件的方法 NGINX
提供动态PHP内容 NGINX使用php-fpm处理PHP页面 Apache可以处理PHP,我们也可以将mpm_event与php-fpm一起使用。 两者都一样好。
资源足迹 NGINX在多处理器环境中可以很好地工作,并且可以有效地使用内存。 在高工作负载下,Apache需要更多的内存和CPU。 NGINX
安全 NGINX配置对于防止DDoS攻击很有用 Apache具有mod_evasive和mod_security模块 两者都一样好。
模块支持 NGINX现在支持动态加载模块 Apache支持许多可以动态加载和卸载的模块 两者都一样好。
操作系统支持 NGINX非常适合Unix / Linux系统。 但是,Windows支持是有限的。 Apache支持所有Unix,Linux和Windows操作系统。 如果使用Windows,则Apache更好。 对于其他人来说,两者都是好的。
支持 NGINX提供付费支持。 也有很多免费的社区驱动的支持。 Apache没有商业支持。 但是,社区支持足以为您提供帮助。 对于大型企业,NGINX更好,因为他们可以获得官方支持。 对于其他所有人,他们两个都有足够的文档和在线资源来满足您的所有需求。

翻译自: https://www.journaldev.com/27148/nginx-vs-apache

apache nginx

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐