問題:
由於開啟了 xdebug 擴充, 導致使用 composer 時提示:
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
所以想在 cli 下不再載入 xdebug
環境:
設定檔分布:
/etc/php├── conf.d│ └── xdebug.ini├── fpm.d├── pear.conf├── php-fpm.conf├── php-fpm.d│ └── www.conf├── php.ini└── php.ini.pacnew
對比 ubuntu 下 通過 apt 安裝的 php 設定檔分布:
/etc/php5/├── cli│ ├── conf.d│ └── php.ini├── fpm│ ├── conf.d│ │ ├── 20-xdebug.ini -> ../../mods-available/xdebug.ini│ ├── php-fpm.conf│ ├── php.ini│ └── pool.d│ └── www.conf└── mods-available └── xdebug.ini
---update ---
在不自行編譯安裝,重新指定各項config參數
的情況下, 也只好手動指定 php.ini 運行了
回複內容:
問題:
由於開啟了 xdebug 擴充, 導致使用 composer 時提示:
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
所以想在 cli 下不再載入 xdebug
環境:
設定檔分布:
/etc/php├── conf.d│ └── xdebug.ini├── fpm.d├── pear.conf├── php-fpm.conf├── php-fpm.d│ └── www.conf├── php.ini└── php.ini.pacnew
對比 ubuntu 下 通過 apt 安裝的 php 設定檔分布:
/etc/php5/├── cli│ ├── conf.d│ └── php.ini├── fpm│ ├── conf.d│ │ ├── 20-xdebug.ini -> ../../mods-available/xdebug.ini│ ├── php-fpm.conf│ ├── php.ini│ └── pool.d│ └── www.conf└── mods-available └── xdebug.ini
---update ---
在不自行編譯安裝,重新指定各項config參數
的情況下, 也只好手動指定 php.ini 運行了
使用兩個不同的 php.ini 設定檔配置不同的運行參數(包括擴充參數),在開啟 cli 或者 fpm 時,通過 -c 參數指定運行所使用的 php.ini 即可。
PHP和PHP-FPM都可以用參數-c指定php.ini設定檔.
執行下列命令可見:
strace -f -o strace.log \/png/php/5.4.45/bin/php -v && \cat strace.log|egrep 'open|read'|grep 'ini'3080 open("/png/php/5.4.45/bin/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3080 open("/png/php/5.4.45/lib/php-cli.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3080 open("/png/php/5.4.45/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3080 open("/png/php/5.4.45/lib/php.ini", O_RDONLY) = 3
PHP會優先讀取php程式所在目錄下的php-cli.ini,訪問到則不再讀取其他ini檔案.
PHP-FPM情況如下:
strace -f -o strace.log \/png/php/5.4.45/sbin/php-fpm -v && \cat strace.log|egrep 'open|read'|grep 'ini'3537 open("/png/php/5.4.45/lib/php-fpm-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3537 open("/png/php/5.4.45/lib/php.ini", O_RDONLY) = 3
PHP-CGI情況如下:
strace -f -o strace.log \/png/php/5.4.45/bin/php-cgi -v && \cat strace.log|egrep 'open|read'|grep 'ini'3568 open("./php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3568 open("/png/php/5.4.45/bin/php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3568 open("/png/php/5.4.45/lib/php-cgi-fcgi.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3568 open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3568 open("/png/php/5.4.45/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)3568 open("/png/php/5.4.45/lib/php.ini", O_RDONLY) = 3
可以把cli目錄下的conf.d 的20-xdebug.ini 設定為禁用應該就可以了