linux - 怎样让 php 在 cli 与 fpm 环境下运行时加载不同的扩展 ?
问题:
由于开启了 xdebug 扩展, 导致使用 composer 时提示:
<code>You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug </code>
所以想在 cli 下不再加载 xdebug
环境:
linux 为 archlinux
php 通过 pacman 安装, 版本 7.0.1
web服务通过 php-fpm 运行
配置文件分布:
<code>/etc/php ├── conf.d │ └── xdebug.ini ├── fpm.d ├── pear.conf ├── php-fpm.conf ├── php-fpm.d │ └── www.conf ├── php.ini └── php.ini.pacnew </code>
对比 ubuntu 下 通过 apt 安装的 php 配置文件分布:
<code>/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 </code>
---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 时提示:
<code>You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug </code>
所以想在 cli 下不再加载 xdebug
环境:
linux 为 archlinux
php 通过 pacman 安装, 版本 7.0.1
web服务通过 php-fpm 运行
配置文件分布:
<code>/etc/php ├── conf.d │ └── xdebug.ini ├── fpm.d ├── pear.conf ├── php-fpm.conf ├── php-fpm.d │ └── www.conf ├── php.ini └── php.ini.pacnew </code>
对比 ubuntu 下 通过 apt 安装的 php 配置文件分布:
<code>/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 </code>
---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配置文件.
执行下列命令可见:
<code>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 </code>
PHP会优先读取php程序所在目录下的php-cli.ini,访问到则不再读取其他ini文件.
PHP-FPM情况如下:
<code>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 </code>
PHP-CGI情况如下:
<code>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 </code>
可以把cli目录下的conf.d 的20-xdebug.ini 设置为禁用应该就可以了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.
