A few years ago I installed Apache 2.2x and PHP 5.3.1 on a Linux server I maintain. I used .tar.gz\'s and built them as instructed (instead of rpms and what-have-you). And
There are several valid ways already mentioned for locating the php.ini file, but if you came across this page because you want to do something with it in a bash script:
path_php_ini="$(php -i | grep 'Configuration File (php.ini) Path' | grep -oP '(?<=\=\>\s).*')"
echo ${path_php_ini}
This works for me:
php -i | grep 'php.ini'
You should see something like:
Loaded Configuration File => /usr/local/lib/php.ini
p.s. To get only the php.inin path
php -i | grep /.+/php.ini -oE
This command should help you to find it
php -r "phpinfo();" | grep php.ini
Run this in the command line:
php -r "echo php_ini_loaded_file().PHP_EOL;"
Use the following commands to find the php.ini
file path in linux.
[root@AnyDirectory ~]# locate php.ini
/etc/php.ini
/etc/php.ini.rpmnew
/usr/share/doc/php-common-5.4.45/php.ini-development
/usr/share/doc/php-common-5.4.45/php.ini-production
or try this another way
[root@AnyDirectory ~]# php --ini
its shows the path result
find / -name php.ini
Hey... it worked for me!