「php-fpm」-

PHP的FastCGI进程管理器。

命令行语法格式

php-fpm [options]

命令描述

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. This is a variant of PHP that will run in the background as a daemon, listening for CGI requests. Output is logged to /var/log/php-fpm.log.

Most options are set in the configuration file. The configuration file is /etc/php-fpm.conf. By default, php-fpm will respond to CGI requests listening on localhost http port 9000. Therefore php-fpm expects your webserver to forward all requests for ‘.php’ files to port 9000 and you should edit your webserver configuration file appropriately.

命令行选项及含义

配置相关选项

-C
不要更改目录到脚本的目录

–php-ini path|file / -c path|file
使用指定的php.ini文件,或者在指定的目录中查找php.ini文件。

–fpm-config file / -y
指定PHP-PFM配置文件的位置。默认/etc/php/php-fpm.conf文件

–test / -t
测试FPM配置文件。如果使用了两次该选项(-tt),则会dump配置文件的信息。

–no-php-ini / -n
不使用php.ini文件。

–define foo[=bar] / -d foo[=bar]
定义INI实体:foo=bar

运行相关选项

-e
生成用于Debug/性能分析的扩展信息。

-p
指定可替换的前缀路径。默认/usr/local。

–pid file / -g
指定PID问家的位置。

–daemonize / -D
强制运行在后台,并忽略配置文件中的守护进程相关的配置。

–nodaemonize / -F
强制在前台运行,并忽略配置文件中的守护进程相关的配置。

–force-stderr / -O
Force output to stderr in nodaemonize even if stderr is not a TTY
即使stderr不是TTY,也可以强制输出到stderr。

–allow-to-run-as-root / -R
允许子进程以ROOT运行。默认是禁用的。

编译及版本信息

–modules / -m
显示编译进PHP-FPM的模块

–info / -i
输出PHP的信息和配置。

–version / -v,–help / -h
版本和帮助等信息。

运行PHP-FPM

运行php-fpm时,如果未指定参数,php-fpm将在后台运行。php-fpm会创建/var/run/php-fpm.pid文件,可以通过检查该文件,判断php-fpm是否运行。

PHP-FPM支持一下的POSIX信号:

  • SIGINT,SIGTERM:立即终止PHP-FPM进程
  • SIGQUIT:优雅的停止PHP-FPM进程
  • SIGUSR1:重新打开日志文件,用于日志切割
  • SIGUSR2:优雅的重新加载所有的worker进程,并重新加载fpm配置和程序。

相关文件

php-fpm.conf
php-fpm服务的配置文件。

php.ini
标准的PHP配置文件。

参考文献