Linux

Where Is the php.ini File?

php.ini locations on Linux across versions and SAPIs, plus the php --ini command that prints the live file.

Last updated

PHP spreads ini files per version and per SAPI: CLI, FPM and Apache module each read their own. Guessing the path from memory fails as often as it works.

The php --ini command exists for exactly this. Run it with the same binary and context you care about and trust its output.

Where PHP stores this, by platform

Linux
/etc/php/[version]/cli/php.ini

One tree per installed version with cli, fpm and apache2 subfolders. Confirm with php --ini; FPM pools add conf.d fragments on top. Restart the SAPI after edits.

Frequently asked questions

How do I find the php.ini my setup actually uses?

Run php --ini. It prints the loaded file plus every scanned extra .ini. That output reflects the exact binary and SAPI you invoked, which varies between CLI and FPM.

Why do phpinfo changes not apply?

Edit the FPM pool or version-specific ini and restart php-fpm. CLI and web SAPIs read different files, so CLI checks will not reflect web changes.

Notice an outdated path? Let us know.