Home > Backend Development > PHP Tutorial > Web server nginx and apache_PHP tutorial

Web server nginx and apache_PHP tutorial

WBOY
Release: 2016-07-13 17:16:54
Original
735 people have browsed it

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template