LinuxWindowsmacOS

Where Does PHP Store php.ini?

PHP reads a different php.ini per SAPI: /etc/php/<version>/cli and /fpm on Linux, chosen install folder on Windows, Homebrew cellar on Mac.

Last updated

PHP ships a separate configuration per interface, and editing the wrong one is the classic wasted afternoon. The CLI, FPM, and web-module SAPIs each read their own php.ini plus a scanned conf.d folder. Same directives, different files.

The php --ini command ends the guessing: it names the loaded file and every extra ini parsed. Package layouts add versioned folders, so upgrades install a fresh set beside the old one. Migrate settings deliberately instead of assuming they carry over.

Where PHP stores this, by platform

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

One tree per PHP version with cli, fpm, and module subfolders. php --ini names the live file. Restart FPM after edits; the CLI picks them up on next run automatically.

Windows
C:\php\php.ini

php.ini beside the install (or C:\php by convention) with ext folder for extensions. Enable an extension by uncommenting its line and pointing extension_dir at the right folder.

macOS
/opt/homebrew/etc/php/[version]/php.ini

Homebrew keeps versioned php.ini files under its etc tree. php --ini resolves the live one; brewed services restart through brew services, not kill signals.

Frequently asked questions

Which php.ini is actually loaded?

Run php --ini. It prints the loaded file plus every scanned extra .ini, which settles CLI versus web confusion instantly. The web SAPI reads a different file in a sibling folder.

I changed php.ini but the website ignores it. Why?

Edit the FPM pool or ini and restart the FPM service. CLI changes never affect running workers; each SAPI only rereads its files on start.

Notice an outdated path? Let us know.