Differences between apache and nginx in PHP Development

Source: Internet
Author: User
Asweallknow: currently, web server software is divided into two main camps: Apache, known for its maturity and stability, and nginx is deployed with fewer memory usage and anti-concurrency. So, as a PHP developer, what should I pay attention to in lamp and lnmp environments... as we all know, currently the web server software is divided into two main camps, one is Apache, known for its maturity and stability, and the new nginx is deployed with fewer memory usage and anti-concurrency. So, as a PHP developer, what should I pay attention to in lamp and lnmp environments? For example, if apache is a blocking type and nginx is an asynchronous non-blocking type, will this affect the execution sequence of the program? What other aspects will be different? We would like to thank each respondent.

Reply content:

As we all know, currently the web server software is divided into two main camps, one is Apache, known for its maturity and stability, and the new nginx is deployed with fewer memory usage and anti-concurrency. So, as a PHP developer, what should I pay attention to in lamp and lnmp environments? For example, if apache is a blocking type and nginx is an asynchronous non-blocking type, will this affect the execution sequence of the program? What other aspects will be different? We would like to thank each respondent.

In fact, you don't have to worry too much about this problem, because small websites do not matter whether apache or nginx is used.
Websites with high traffic volumes use not only apache or nginx, but also lnmpa architecture.
Nginx is highly capable of handling static files and high concurrency, while apache is more capable of handling dynamic programs. Therefore, large websites generally use nginx as a reverse proxy. static files are directly returned and dynamic requests are forwarded to apache.

Now, both Apache and Nginx forward requests to php-fpm. There is no difference in code development.

If your application is not asynchronous and non-blocking, those will not be affected.

Both apache and nginx can use php-fpm.

LNPP passed ......

NGINX is responsible for processing static resources. APACHE processes dynamic scripts, also known as lnmpa.

I recently stepped on this pitfall. At present, the small site PV20W +, a single machine with 4 cores and 4 GB memory, uses the lanmp (php5.5 + mysql5.6 + apache 2.4 + nginx 1.6) environment. Note that it is a single machine, the CPU usage is usually 100% during peak periods. The previously used lnmp (php5.1 + nginx 1.4 + mysql 5.1) is the same concurrency. during peak periods, the CPU usage does not exceed 70%, and the load has been very stable, I am currently trying to replace it with the Linux eye package for lnmp (nginx 1.6 + php 5.6!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.