发布于2026-07-21 阅读(0)
扫一扫,手机访问
在PHP的生态中,php-cgi和php-fpm的关系常常让新手感到困惑。实际上,默认的php-cgi并未集成php-fpm功能,但通过打补丁可以轻松实现。下面先看看未打补丁和已打补丁的php-cgi帮助信息对比:
未打补丁时,php-cgi的帮助信息如下:
$ ./php-cgi -h
Usage: php-cgi.patch [-q] [-h] [-s] [-v] [-i] [-f ]
php-cgi.patch [args...]
-a Run interactively
-b | Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c | Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f Parse . Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z Load Zend extension .
-T Measure execution time of script repeated times.
注意看,默认的php-cgi帮助信息中并没有`-x`和`-y`这两个选项。而一旦打上php-fpm补丁,选项就会发生变化,具体如下:
$ php-cgi -h
Usage: php [-q] [-h] [-s] [-v] [-i] [-f ]
php [args...]
-a Run interactively
-b | Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c | Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f Parse . Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-x, --fpm Run in FastCGI process manager mode.
-y, --fpm-config
Specify alternative path to FastCGI process manager config file.
-z Load Zend extension .
-T Measure execution time of script repeated times.
打补丁后,php-cgi就可以通过`--fpm`和`--fpm-config`参数以php-fpm模式启动了,例如:
$ php-cgi --fpm --fpm-config ~/php/etc/php-fpm.conf
需要说明的是,这个过程并不复杂,核心就是下载源码和对应的补丁文件。下面以php-5.2.10版本为例,演示具体操作步骤:
1. 首先,从 http://museum.php.net/ 下载对应版本的源码包。在终端中执行以下命令:
$ cd ~/ && mkdir src && cd src && wget "http://museum.php.net/php5/php-5.2.10.tar.bz2" && tar -jxf php-5.2.10.tar.bz2
2. 然后,到 http://php-fpm.org/downloads/ 下载对应版本的补丁文件,并执行打补丁操作:
$ cd ~/src && wget "http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz" && gzip -cd php-5.2.10-fpm-0.5.13.diff.gz | patch -d php-5.2.10 -p1
完成以上步骤,补丁就打好了。之后在编译PHP时,`./configure`参数中就可以使用`--enable-fpm`选项了。其他版本的PHP应用此方法也是一样的道理。
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
8