search
HomeBackend DevelopmentPHP TutorialWeb server nginx and apache_PHP tutorial
Web server nginx and apache_PHP tutorialJul 13, 2016 pm 05:16 PM
apachenginxphpwebandcontentPrepareserverof

I am planning to set up a PHP web server recently. The following content is for reference.

1. Advantages of nginx over apache:
Lightweight, it also serves as a web service, and takes up less memory and resources than apache
Anti-concurrency, nginx processes requests asynchronously and non-blockingly, while apache is blocking . Under high concurrency, nginx can maintain low resource consumption and high performance
Highly modular design, writing modules is relatively simple
The community is active and various high-performance modules are produced quickly
Advantages of apache over nginx :

rewrite, is more powerful than nginx’s rewrite

Dynamic page

There are so many modules, you can basically find everything you can think of
Few bugs, nginx has relatively many bugs

Super stable

Existence is the reason. Generally speaking, web services that require performance use nginx. If you don’t need performance and just want stability, then use apache . The various functional modules of the latter are implemented better than the former. For example, the ssl module is better than the former and has more configurable items. One thing to note here is that the epoll (kqueue on freebsd) network IO model is the fundamental reason for nginx's high processing performance, but not all situations are epoll's winner. If it provides static services, only a few file, apache's select model may be more performant than epoll. Of course, this is just an assumption based on the principles of the network IO model. The real application still needs to be tested in practice.

2. As a Web server: Compared with Apache, Nginx uses fewer resources, supports more concurrent connections, and reflects higher efficiency. This makes Nginx especially popular with virtual hosts. Providers welcome. In the case of high connection concurrency, Nginx is a good alternative to the Apache server: Nginx is one of the software platforms often chosen by bosses in the virtual host business in the United States. It can support responses of up to 50,000 concurrent connections, Thanks to Nginx for choosing epoll and kqueue as the development model for us.
Nginx as a load balancing server: Nginx can not only directly support Rails and PHP programs to serve externally internally, but also support it as a load balancing server. HTTP proxy server provides external services. Nginx is written in C, and its system resource overhead and CPU usage efficiency are much better than Perlbal.
As a mail proxy server: Nginx is also a very excellent mail server Proxy server (one of the first purposes of developing this product is also as a mail proxy server), Last.fm describes the successful and wonderful use experience.
Nginx is a very simple installation, the configuration file is very Simple (can also support perl syntax), very few bugs server: Nginx is very easy to start, and can run almost 7*24 without interruption, even if it runs for several months, it does not need to be restarted. You can still have uninterrupted service Upgrade the software version when necessary.

3. Nginx configuration is simple, Apache is complex
Nginx static processing performance is more than 3 times higher than Apache
Apache’s support for PHP is relatively simple, Nginx needs to be used with other backends
Apache has more components than Nginx
Now Nginx is the web server The first choice

4. The core difference is that apache is a synchronous multi-process model, one connection corresponds to one process; nginx is asynchronous, multiple connections (10,000 levels) can correspond to one process

5. nginx handles static files well and consumes less memory. But there is no doubt that apache is still the mainstream and has many rich features. So it still needs to be matched. Of course, if you can determine that nginx is suitable demand, then using nginx will be a more economical way.

Apache has the disadvantage of not supporting multi-core processing load. It is recommended to use nginx as the front end and apache as the back end. For large websites, it is recommended to use nginx’s self-generated cluster function

6. Judging from personal past usage, the load capacity of nginx is much higher than that of apache. The latest server also uses nginx. Moreover, after changing the configuration of nginx, you can -t test whether there is any problem with the configuration. When apache restarts, it is found that the configuration is wrong and it will crash. I will be very careful when making changes. Now there are many cluster sites. The front-end nginx is anti-concurrency, and the back-end apache cluster , the cooperation is also good.


7. nginx is useless for handling dynamic requests. Generally, dynamic requests need to be done by apache, and nginx is only suitable for static and reverse.

8. From my personal experience, nginx is a very good front-end server with good load performance. I opened nginx on Laoben and used webbench to simulate 10,000 static file requests. Effortless. Apache has good support for languages ​​​​such as php. In addition, apache has a strong support network and has been developed for a longer period of time than nginx.

9. There are two main reasons why Nginx is better than apache: 1 .Nginx itself is a reverse proxy server 2.Nginx supports 7-layer load balancing; others, of course, Nginx may support higher concurrency than apache, but according to NetCraft statistics, April 2011 statistics, Apache still holds the 62.71%, while Nginx is 7.35%, so in general, Aapche is still the first choice for most companies, because its mature technology and development community already have very good performance.

10. Your needs for web server determine your choice. In most cases, nginx is better than APACHE, such as static file processing, PHP-CGI support, reverse proxy function, front-end Cache, maintaining connections, etc. In the Apache+PHP (prefork) mode, if PHP processing is slow or the front-end pressure is high, it is easy for the number of Apache processes to surge, resulting in a denial of service.

11. You can take a look at the nginx lua module: https://github.com/chaoslaw... Apache has more modules than nginx, you can use lua directly Implementation of apache is the most popular, why? Most people are too lazy to update to nginx or learn new things

12. For nginx, I like that its configuration file is very concise. Regular configuration makes many things simple and efficient. It takes up less resources and has powerful proxy functions. It is very suitable for front-end response servers

13. Apache has advantages in processing dynamics. Nginx has better concurrency and low CPU memory usage. If rewrite is frequent, Then it’s Apache

http://www.cnblogs.com/roucheng/

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/626664.htmlTechArticleI am planning to set up a php web server recently. The following content is for reference. 1. Advantages of nginx over apache: lightweight, can also serve as a web service, takes up less memory and resources than apache, resists merging...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Web Speech API开发者指南:它是什么以及如何工作Web Speech API开发者指南:它是什么以及如何工作Apr 11, 2023 pm 07:22 PM

​译者 | 李睿审校 | 孙淑娟Web Speech API是一种Web技术,允许用户将语音数据合并到应用程序中。它可以通过浏览器将语音转换为文本,反之亦然。Web Speech API于2012年由W3C社区引入。而在十年之后,这个API仍在开发中,这是因为浏览器兼容性有限。该API既支持短时输入片段,例如一个口头命令,也支持长时连续的输入。广泛的听写能力使它非常适合与Applause应用程序集成,而简短的输入很适合语言翻译。语音识别对可访问性产生了巨大的影响。残疾用户可以使用语音更轻松地浏览

如何使用Docker部署Java Web应用程序如何使用Docker部署Java Web应用程序Apr 25, 2023 pm 08:28 PM

docker部署javaweb系统1.在root目录下创建一个路径test/appmkdirtest&&cdtest&&mkdirapp&&cdapp2.将apache-tomcat-7.0.29.tar.gz及jdk-7u25-linux-x64.tar.gz拷贝到app目录下3.解压两个tar.gz文件tar-zxvfapache-tomcat-7.0.29.tar.gztar-zxvfjdk-7u25-linux-x64.tar.gz4.对解

web端是什么意思web端是什么意思Apr 17, 2019 pm 04:01 PM

web端指的是电脑端的网页版。在网页设计中我们称web为网页,它表现为三种形式,分别是超文本(hypertext)、超媒体(hypermedia)和超文本传输协议(HTTP)。

web前端和后端开发有什么区别web前端和后端开发有什么区别Jan 29, 2023 am 10:27 AM

区别:1、前端指的是用户可见的界面,后端是指用户看不见的东西,考虑的是底层业务逻辑的实现,平台的稳定性与性能等。2、前端开发用到的技术包括html5、css3、js、jquery、Bootstrap、Node.js、Vue等;而后端开发用到的是java、php、Http协议等服务器技术。3、从应用范围来看,前端开发不仅被常人所知,且应用场景也要比后端广泛的太多太多。

深入探讨“高并发大流量”访问的解决思路和方案深入探讨“高并发大流量”访问的解决思路和方案May 11, 2022 pm 02:18 PM

怎么解决高并发大流量问题?下面本篇文章就来给大家分享下高并发大流量web解决思路及方案,希望对大家有所帮助!

web前端打包工具有哪些web前端打包工具有哪些Aug 23, 2022 pm 05:31 PM

web前端打包工具有:1、Webpack,是一个模块化管理工具和打包工具可以将不同模块的文件打包整合在一起,并且保证它们之间的引用正确,执行有序;2、Grunt,一个前端打包构建工具;3、Gulp,用代码方式来写打包脚本;4、Rollup,ES6模块化打包工具;5、Parcel,一款速度极快、零配置的web应用程序打包器;6、equireJS,是一个JS文件和模块加载器。

Python轻量级Web框架:Bottle库!Python轻量级Web框架:Bottle库!Apr 13, 2023 pm 02:10 PM

和它本身的轻便一样,Bottle库的使用也十分简单。相信在看到本文前,读者对python也已经有了简单的了解。那么究竟何种神秘的操作,才能用百行代码完成一个服务器的功能?让我们拭目以待。1. Bottle库安装1)使用pip安装2)下载Bottle文件https://github.com/bottlepy/bottle/blob/master/bottle.py2.“HelloWorld!”所谓万事功成先HelloWorld,从这个简单的示例中,了解Bottle的基本机制。先上代码:首先我们从b

web浏览器是什么web浏览器是什么Sep 26, 2022 pm 05:00 PM

web浏览器是指“网页浏览器”,是一种用来检索、展示以及传递Web信息资源的应用程序;简单来说就是是用来浏览网络页面的软件。web浏览器主要通过HTTP协议与网页服务器交互并获取网页,这些网页由URL指定,文件格式通常为HTML,并由MIME在HTTP协议中指明。一个网页中可以包括多个文档,每个文档都是分别从服务器获取的。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.