Home >Backend Development >PHP Problem >What web server does php use?
There are generally two commonly used web servers for php: 1. apache; 2. nginx. Let me introduce to you the differences between these two servers.
The difference between apache and nginx:
1. The core difference between the two is that apache is a synchronous multi-process model, and one connection corresponds to one process; nginx is asynchronous , multiple connections can correspond to one process. nginx handles static files well and consumes less memory. But there is no doubt that apache is still the current mainstream and has many rich features, so it still needs to be matched. Of course, if it is determined that nginx meets the needs, then using nginx will be a more economical way.
2. The load capacity of nginx is much higher than that of apache. The latest server also uses nginx. And after changing the configuration of nginx, you can -t test whether there is any problem with the configuration.
3. When apache is restarted and it is found that the configuration is wrong, it will crash. When making changes, you will be very careful. Now there are many cluster sites, the front-end nginx anti-concurrency, the back-end apache cluster, the cooperation is also good.
4. It is useless for nginx to handle dynamic requests. Generally, apache is required to handle dynamic requests. nginx is only suitable for static and reverse requests.
5. From experience, nginx is a very good front-end server with good load performance. With nginx, it is effortless to use webbench to simulate 10,000 static file requests. Apache has good support for languages such as php. In addition, apache has a strong support network. It has been developed longer than nginx and has fewer bugs. However, apache has the disadvantage of not supporting multi-core processing loads. It is recommended to use nginx for the front end and back end. apache. For large websites, it is recommended to use the cluster function of nginx.
6. In most cases, nginx is better than APACHE, such as static file processing, PHP-CGI support, reverse proxy function, front-end Cache, connection maintenance, etc. In 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.
7. Apache has advantages in processing dynamics. Nginx has better concurrency and low CPU memory usage. If rewrite is frequent, then Apache is the best!
8. Generally speaking, for web services that require performance, use nginx. If you don't need performance and just want stability, then use apache.
Recommended tutorial: PHP video tutorial
The above is the detailed content of What web server does php use?. For more information, please follow other related articles on the PHP Chinese website!