.user.ini中sendmail_path不作用于子目录是否属于PHP Bug?
Is
sendmail_path in .user.ini failing to apply to subdirectories a PHP bug? Short answer: No, this isn’t a PHP bug — it’s intentional behavior rooted in how PHP handles process-level configuration in FastCGI/FPM setups (which is what your WHM environment uses for PHP 5.6).
Here’s why this happens
Let’s break down the key factors:
- Directive scope rules: In PHP 5.6,
sendmail_pathis categorized as aPHP_INI_SYSTEMdirective. While.user.inifiles let you tweak manyPHP_INI_PERDIRsettings on a per-request, per-directory basis,PHP_INI_SYSTEMdirectives are meant to be set once when the PHP process starts — they can’t be dynamically adjusted mid-request for subdirectories. - PHP-FPM process lifecycle: WHM runs PHP via PHP-FPM, where worker processes are spawned upfront. When a process launches, it reads the initial config (including the
.user.inifrom your parent directory). Once the process is running, it can’t reinitializesendmail_path— this setting defines the sendmail binary path for the entire process, not individual requests. Other.user.inisettings (likemax_execution_timeordisplay_errors) are request-level, so they can be overridden per directory because they’re applied each time a request is handled. - Subdirectory
.user.inilimitations: Even if you addsendmail_pathto a subdirectory’s.user.ini, PHP will ignore it. The process already locked in that value at startup. Placing a fullphp.iniin the subdirectory might work (since it can trigger a process restart in some setups), but as you noted, that defeats the point of using.user.inifor centralized, per-user config.
Fixes to get consistent sendmail_path across subdirectories
If you want sendmail_path to apply everywhere under your account, use one of these methods instead:
- WHM’s PHP Configuration Editor: Use WHM’s built-in tool to set
sendmail_pathglobally for PHP 5.6 (or per-user, if your WHM setup allows it). This ensures the directive is picked up when PHP-FPM processes start, and it will work across all subdirectories. - User-level
php.ini: Place aphp.inifile in your account’s home directory (or the directory where PHP-FPM processes launch for your user). This file is read during process startup, sosendmail_pathwill take effect for all your account’s requests.
内容的提问来源于stack exchange,提问作者Micah
相关产品推荐
相关产品推荐

