0%

直接连接 PHP-FPM

直接连接 PHP-FPM

步骤

  • 工具安装
    1
    2
    3
    4
    5
    # centos
    yum --enablerepo=epel install fcgi

    # ubuntu
    apt-get install libfcgi0ldbl
  • 修改配置
    找到 PHP-FPM 配置文件,例如: php-fpm.conf

    1
    ping.path = /ping     #去掉这条语句的屏蔽
  • 重启 PHP-FPM

  • 连接 PHP-FPM

    1
    2
    3
    4
    SCRIPT_NAME=/ping \
    SCRIPT_FILENAME=/ping \
    REQUEST_METHOD=GET \
    cgi-fcgi -bind -connect 127.0.0.1:PORT

    如果正确将得到如下返回:

    1
    2
    3
    4
    5
    6
    X-Powered-By: PHP/7.0.3
    Content-type: text/plain;charset=UTF-8
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    Cache-Control: no-cache, no-store, must-revalidate, max-age=0

    pong
  • SCRIPT_FILENAME 改为本地其他php文件路径,则可直接执行本地其他文件

Reference & Thanks