在/usr/local/php/etc/目錄下新建php2.ini
復制php.ini 內容到php2.ini 或cp php.ini 也行。
配置php-fpm 參數:
Usage: php [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F]
-c <path>|<file> 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
-h This help
-i PHP information
-m Show compiled in modules
-v Version number
-p, --prefix <dir>
Specify alternative prefix path to FastCGI process manager (default: /usr/local/php).
-g, --pid <file>
Specify the PID file location.
-y, --fpm-config <file>
Specify alternative path to FastCGI process manager config file.
-t, --test Test FPM configuration and exit
-D, --daemonize force to run in background, and ignore daemonize option from config file
-F, --nodaemonize
force to stay in foreground, and ignore daemonize option from config file
-R, --allow-to-run-as-root
Allow pool to run as root (disabled by default)
其中:-c
<path>|<file> Look for php.ini file in this directory
指定ini文件的目錄
所以:
php-fpm -c /usr/local/php/etc/php2.ini
重啟nginx是查看沒有改變!
service nginx reload
要重啟php-fpm
但是提示:
ERROR: An another FPM instance seems to already listen on /tmp/php-cgi.sock
ERROR: FPM initialization failed
所以先停止php-fpm 服務在指定php.ini 文件
/etc/init.d/php-fpm stop
php-fpm -c /usr/local/php/etc/php2.ini

--------------------------------------------------------------------------------------------------------
隱藏X-Powered-By
則修改 php.ini 文件 設置 expose_php = Off
記得重啟是重啟php-fpm 而不是nginx,重啟php-fpm , 如果修改了php.ini配置目錄還要重新-c 配置ini目錄
