Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences in the operation of PHP such as mod_php, FastCGI, PHP-FPM, etc.

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "what are the differences in the operation of PHP, such as mod_php, FastCGI, PHP-FPM, etc.". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the differences in the operation of PHP, such as mod_php, FastCGI, PHP-FPM, and so on?"

What is a PHP processor (PHP handlers)?

The first thing to keep in mind is that any Web server (Apache, Nginx, etc.) is designed to send static resources such as html, pictures, etc., to the user, and the Web server itself cannot interpret any dynamic scripts (PHP, Python, etc.). The PHP processor is used to interpret the PHP code in the Web application, and interpret it as HTML or other static resources, and then transmit the parsed result to the Web server, and finally send it to the user by the Web server. Most Web servers cannot parse PHP code, so it needs a program that can parse PHP code, which is the PHP processor.

Mod_php

First, take a look at running PHP as an Apache module. Mod_php is now available in all versions of Linux software repositories, so it is easy to install.

When PHP runs in Apache as a module, the PHP interpreter is "embedded" in the Apache process. Apache does not call any external PHP processes, so this approach allows Apache to communicate better with PHP. However, when PHP is run in this way, even if Apache provides only static resources (such as HTML), every child process of Apache will load mod_php, resulting in more memory overhead than normal.

Another disadvantage of running in this way is that it only works with Apache. In addition, this approach is not appropriate in small VPS and large websites, because large websites may have a lot of static resources that do not need to be interpreted by PHP programs.

Advantages:

1. Easy to install and update

two。 Capacity configuration

Disadvantages:

1. Can only work with Apache

two。 Increased Apache child process memory overhead

3. When you change the php.ini file, you need to restart Apache

FastCGI

FastCGI is a common protocol interface between interactive programs and Web servers, and it is a variant of early CGI (Common Gateway Interface). Compared to CGI, FastCGI reduces the overhead of interacting with the Web server and can handle more requests at a time.

Apache can use FastCGI as mod_fcgid. Other Web servers, such as lighttpd, nginx, Cherokee, and even Microsoft IIS, can also use FastCGI. With FastCGI, you can set up multiple versions of PHP at the same time, which is useful in some cases.

FastCGI also uses suexec to support different users to use their own instances of PHP. This feature is particularly important for improving security in a shared environment. FastCGI not only ensures performance, but also reduces the memory overhead of Web servers.

Advantages:

1. Compatible with most Web servers

two。 Takes up less memory than mod_php

3. More configuration items, including multiple versions of PHP and suexec

Shortcoming

1. Complex configuration

two。 Not well known by everyone

PHP-FPM (FastCGI Process Manager)

PHP-FPM is the latest way for Web servers to use PHP, and it is another implementation of PHP FastCGI. PHP-FPM is very useful for Web applications running on small VPS and multiple servers. At the same time, it can also be used by any FastCGI-compatible Web server.

PHP-FPM enables administrators to gracefully stop and start the PHP worker process without losing any queries. This allows us to update the configuration and binaries step by step without losing any queries. It also allows us to urgently restart the process in the event of any accidental damage.

Advantages:

1. Compatible with most Web servers

two。 Takes up less memory than mod_php

3. More configuration items, including multiple versions of PHP and suexec

Shortcoming

1. Complex configuration

two。 Not well known by everyone

Add: four ways for Apache to run PHP

Mod_php (DSO,Dynamic Shared Object)

CGI

SuPHP

FastCGI

Thank you for your reading, the above is the content of "what are the differences in the operation of mod_php, FastCGI, PHP-FPM and other PHP". After the study of this article, I believe you have a deeper understanding of the differences in the operation of mod_php, FastCGI, PHP-FPM and other PHP, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report