zoukankan      html  css  js  c++  java
  • [Linux]PHP-FPM与NGINX的两种通讯方式

    一、通过监听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进程间通讯

    通过配置php-fpm.d/www.conf Listen 项,php-fpm主进程启动时会在这个目录创建一个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 = nginx
    group = 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 0660
    listen.owner = nginx
    listen.group = nginx
    listen.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;
    
            }
  • 相关阅读:
    从MVC和三层架构说到ssh整合开发-下
    Codeforces Round #226 (Div. 2)--A Bear and Raspberry
    ISA95的抽象惯例
    Difference between End-to-end testing and System testing
    javascript Date format(js日期格式化)
    给easyui datebox扩展一个清空按钮
    easyui combobox开启搜索自动完成功能
    给你的webstorm添加快速生成注释得快捷键
    location.origin兼容IE
    将json转换成struts参数
  • 原文地址:https://www.cnblogs.com/yiyide266/p/9568749.html
Copyright © 2011-2022 走看看