[Linux]PHP-FPM與NGINX的兩種通訊方式

來源:互聯網
上載者:User

標籤:ipv6   use   設定   path_info   list   syntax   man   sse   this   

一、通過監聽TCP連接埠通訊

php-fpm.d/www.conf

; The address on which to accept FastCGI requests.; Valid syntaxes are:;   ‘ip.add.re.ss:port‘    - to listen on a TCP socket to a specific IPv4 address on;                            a specific port;;   ‘[ip:6:addr:ess]:port‘ - to listen on a TCP socket to a specific IPv6 address on;                            a specific port;;   ‘port‘                 - to listen on 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;            fastcgi_split_path_info ^(.+\.php)(.*)$;            fastcgi_param PATH_INFO $fastcgi_path_info;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            include        fastcgi_params;        }

二、通過unix socket進程間通訊

先選定一個目錄建立一個空.sock檔案,例如/run/php-fpm.sock(注意不應選用/tmp目錄),再進行配置

php-fpm.d/www.conf

1.設定通訊方式

; The address on which to accept FastCGI requests.; Valid syntaxes are:;   ‘ip.add.re.ss:port‘    - to listen on a TCP socket to a specific IPv4 address on;                            a specific port;;   ‘[ip:6:addr:ess]:port‘ - to listen on a TCP socket to a specific IPv6 address on;                            a specific port;;   ‘port‘                 - to listen on 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.設定建立.sock檔案的存取權限,以便nginx進程能夠訪問php-fpm建立的.sock

; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user‘s group;       will be used.user = nginxgroup = nginx
; Set permissions for unix socket, if one is used. In Linux, read/write; permissions must be set in 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;                 mode is set to 0660listen.owner = nginxlisten.group = nginxlisten.mode = 0660

nignx.conf

location ~ \.php {            root           /lroot/wwwroot/test;            fastcgi_pass   unix:/run/php-fpm.sock;            fastcgi_index  index.php;            fastcgi_split_path_info ^(.+\.php)(.*)$;            fastcgi_param PATH_INFO $fastcgi_path_info;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            include        fastcgi_params;        }

 

[Linux]PHP-FPM與NGINX的兩種通訊方式

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.