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

How to realize Communication between nginx and php-fpm

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Today, I will talk to you about how to achieve communication between nginx and php-fpm. Many people may not know much about it. In order to make you understand better, the editor summed up the following content for you. I hope you can get something according to this article.

Unix socket is faster than tcp and consumes less resources because socket communicates between nginx and php-fpm processes, while tcp needs to go through a local loopback driver and apply for temporary ports and tcp related resources.

Unix socket will appear to be less stable, and when the number of concurrent connections breaks out, a large number of long-term caches will be generated. In the absence of connection-oriented protocol support, large packets are likely to go wrong directly and will not return an exception. The connection-oriented protocol such as TCP can guarantee the correctness and integrity of communication.

Tcp mode: tcp protocol listens to native port 9000, which needs to be connected through the network, occupying ports and network resources.

Socket mode: use unix domain socket to connect sockets / dev/shm/php-cgi.sock, do not go to the network, faster

The nginx server module sets the fastcgi:

Tcp mode:

Fastcgi_pass 127.0.0.1:9000

Socket mode:

Fastcgi_pass unix:/dev/shm/php-cgi.sock

Configure link snooping in php-fpm.conf:

Tcp mode:

Listen = 127.0.0.1 9000

Socket mode:

Listen = / dev/shm/php-cgi.sock

/ dev/shm is the memory file system mount point, which is faster than the default / tmp/php-cgi.sock disk file

After reading the above, do you have any further understanding of how to communicate between nginx and php-fpm? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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

Internet Technology

Wechat

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

12
Report