php-fpm 无法运行cli,linux-怎样让php在cli与fpm环境下运行时加载不同的扩展?
問題:
由于開啟了 xdebug 擴展, 導致使用 composer 時提示:
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
所以想在 cli 下不再加載 xdebug
環境:
linux 為 archlinux
php 通過 pacman 安裝, 版本 7.0.1
web服務通過 php-fpm 運行
配置文件分布:
/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 ---
https://launchpadlibrarian.net/92790964/buildlog_ubuntu-hardy-amd64.php5_5.2.4-2ubuntu5.23_BUILDING.txt.gz
https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/php
在不自行編譯安裝,重新指定各項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
環境:
linux 為 archlinux
php 通過 pacman 安裝, 版本 7.0.1
web服務通過 php-fpm 運行
配置文件分布:
/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 ---
https://launchpadlibrarian.net/92790964/buildlog_ubuntu-hardy-amd64.php5_5.2.4-2ubuntu5.23_BUILDING.txt.gz
https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/php
在不自行編譯安裝,重新指定各項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 設置為禁用應該就可以了
本條技術文章來源于互聯網,如果無意侵犯您的權益請點擊此處反饋版權投訴
本文系統來源:php中文網
超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生總結
以上是生活随笔為你收集整理的php-fpm 无法运行cli,linux-怎样让php在cli与fpm环境下运行时加载不同的扩展?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: timthumb.php外链,如何解决W
- 下一篇: linux 其他常用命令