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 FileScan for additional .ini files
Web context (FPM/Apache)
Create a temporary file with:
<?php phpinfo();
Open it in your browser and check:
Loaded Configuration FileAdditional .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.iniC:\wamp64\bin\php\php<version>\php.ini
If unsure, use:
find / -name php.ini 2>/dev/null
Applying changes safely
- Back up the current file.
- Change one setting at a time.
- Validate syntax and restart the relevant service.
- Re-check with
php --iniorphpinfo().
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:
- confirm active ini path in the exact runtime context
- update mail directives
- restart PHP runtime
- send a test message
- assert received output in a test inbox
For deterministic checks, use MailSlurp test inboxes and PHP email receive examples.