When PHP behavior looks inconsistent, the root cause is often simple: you edited the wrong php.ini file.

This guide shows how to find the active config file for both CLI and web requests, then verify your changes safely.

Why php.ini matters

php.ini controls runtime defaults such as:

  • memory limits
  • upload size constraints
  • error reporting and logging
  • mail transport options (sendmail_path, SMTP-related behavior)

PHP may load different ini files for CLI and FPM/Apache, so always verify both contexts.

Fastest way to identify the active file

CLI context

php --ini

Look for:

  • Loaded Configuration File
  • Scan for additional .ini files

Web context (FPM/Apache)

Create a temporary file with:

<?php phpinfo();

Open it in your browser and check:

  • Loaded Configuration File
  • Additional .ini files parsed

Delete this file after debugging to avoid exposing server details.

Typical php.ini locations

Linux (package installs)

  • /etc/php/<version>/cli/php.ini
  • /etc/php/<version>/fpm/php.ini
  • /etc/php/<version>/apache2/php.ini

macOS (Homebrew)

  • /opt/homebrew/etc/php/<version>/php.ini (Apple Silicon)
  • /usr/local/etc/php/<version>/php.ini (Intel)

Windows (XAMPP/WAMP/manual)

  • C:\xampp\php\php.ini
  • C:\wamp64\bin\php\php<version>\php.ini

If unsure, use:

find / -name php.ini 2>/dev/null

Applying changes safely

  1. Back up the current file.
  2. Change one setting at a time.
  3. Validate syntax and restart the relevant service.
  4. Re-check with php --ini or phpinfo().

Example (Linux + PHP-FPM):

sudo cp /etc/php/8.2/fpm/php.ini /etc/php/8.2/fpm/php.ini.bak
sudo systemctl restart php8.2-fpm

Common pitfalls

Edited CLI ini but testing through web server

Result: command-line scripts behave differently from your app.

Overridden by additional ini files

Values in files like conf.d/*.ini can supersede php.ini defaults.

Changed mail settings but didn't verify delivery path

For app-level email workflows, validate with an end-to-end test inbox, not only local send success.

Practical email debugging workflow

If you are changing PHP mail behavior:

  1. confirm active ini path in the exact runtime context
  2. update mail directives
  3. restart PHP runtime
  4. send a test message
  5. assert received output in a test inbox

For deterministic checks, use MailSlurp test inboxes and PHP email receive examples.