[Linux] Two kinds of communication methods of PHP-FPM and Nginx

Source: Internet
Author: User
Tags fpm

One, by listening to TCP port communication

Php-fpm.d/www.conf

; The address onwhichTo accept FastCGI requests.;   Valid syntaxes is:; 'Ip.add.re.ss:port'-To listen in a TCP socket to a specific IPv4 address on;   a specific port;; '[ip:6:addr:ess]:p ort'-To listen in a TCP socket to a specific IPv6 address on;   a specific port;; 'Port'-To listen in a TCP socket to all addresses; (IPv6 and IPv4-mapped) on a specific port;; '/path/to/unix/socket'-To listen on a UNIX socket.; Note:this value is Mandatory.listen=127.0.0.1:9000

Nignx.conf

Location ~ \.php {            root           /lroot/wwwroot/test;            Fastcgi_pass   127.0. 0.1:9000;            Fastcgi_index  index.php;             ^ (. +\.php) (. *) $;            Fastcgi_param path_info $fastcgi _path_info;            Fastcgi_param  script_filename  $document _root$fastcgi_script_name;            Include        fastcgi_params;        }

Second, through the UNIX socket interprocess communication

Select a directory to create an empty. Sock file, such as/run/php-fpm.sock ( Note that the/tmp directory should not be selected), and then configure

Php-fpm.d/www.conf

1. Set up a communication mode

; The address onwhichTo accept FastCGI requests.;   Valid syntaxes is:; 'Ip.add.re.ss:port'-To listen in a TCP socket to a specific IPv4 address on;   a specific port;; '[ip:6:addr:ess]:p ort'-To listen in a TCP socket to a specific IPv6 address on;   a specific port;; 'Port'-To listen in a TCP socket to all addresses; (IPv6 and IPv4-mapped) on a specific port;; '/path/to/unix/socket'-To listen on a UNIX socket.; Note:this value is Mandatory.listen=/run/php-fpm.sock

2. Set the access permission to create the. sock file so that the Nginx process can access the PHP-FPM created. Sock

; Unix user/group of processes; Note:the user is mandatory. If The group is not set, the default user   " s       Group  ; would be used.user  = Nginxgroup  = Nginx 
 for if one is used. In Linux, read/write on order to allow connections from a Web server. many; BSD-derived systems allow connections regardless of permissions.; Default Values:user and group are set as the running user;                  0660   == 0660

Nignx.conf

Location ~ \.php {            root           /lroot/wwwroot/test;            Fastcgi_pass   Unix:/run/php-fpm.sock;            Fastcgi_index  index.php;             ^ (. +\.php) (. *) $;            Fastcgi_param path_info $fastcgi _path_info;            Fastcgi_param  script_filename  $document _root$fastcgi_script_name;            Include        fastcgi_params;        }

[Linux] Two kinds of communication methods of PHP-FPM and Nginx

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.