修改PHP 加載loaded configuration file 目錄


 

在/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目錄


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM