Ever needed to make a quick adjustment to the php.ini file but you weren’t sure where it was? Here’s a quick command you can use:
曾经需要对php.ini文件进行快速调整,但是您不确定它在哪里吗? 您可以使用以下快速命令:
php -i | grep php.ini
php -i | grep php.ini
What this does is tell the php command-line application to run a phpinfo() and output it in text format to the shell. Then filtering it through grep to find the actual line, which will display like so:
这样做是告诉php命令行应用程序运行phpinfo()并将其以文本格式输出到外壳。 然后通过grep过滤它以找到实际的行,该行将显示如下:
Configuration File (php.ini) Path => /etc/php.ini
配置文件(php.ini)路径=> /etc/php.ini
You can, of course, always put a new php file in your web server root directory and add in the following:
当然,您始终可以在Web服务器的根目录中放置一个新的php文件,并添加以下内容:
<?php
<?php
phpinfo();
phpinfo();
And then browse to it in your browser.
然后在浏览器中浏览到它。
翻译自: https://www.howtogeek.com/50853/find-the-php-ini-file-location-from-the-command-line/