Skip to content

MultiPHP INI Editor versus .htaccess — where to put PHP directives on cPanel

When a PHP setting belongs in the MultiPHP INI Editor, when it belongs in a per-account user.ini, and when .htaccess is the wrong answer entirely depending on the PHP handler.

A customer needs memory_limit = 512M for one account. Three operators give three different answers — .htaccess, php.ini, or “open a ticket so we can edit /usr/local/lib/php.ini.” Two of those three are wrong depending on the handler. cPanel exposes the supported channel: the MultiPHP INI Editor for account-scoped overrides, and per-user .user.ini for per-directory tweaks. Anything in .htaccess only works under specific handlers and breaks silently under others.

What’s happening

php_value and php_admin_value in .htaccess only work when PHP runs as an Apache module (DSO) or under suPHP. Under FastCGI, LSAPI, or PHP-FPM — which is what every modern cPanel build uses — Apache does not handle PHP directives anymore and silently ignores them. The replacement is .user.ini, parsed by PHP itself per directory. Server-wide and per-account directives live in proper .ini files: /opt/cpanel/ea-php82/root/etc/php.ini for the server, and per-account files under /var/cpanel/users/<user>/php.ini (the MultiPHP INI Editor manages the visible subset).

How to verify

For a given account, find out which handler is in play and where overrides will actually be read:

whmapi1 php_get_vhost_versions
whmapi1 php_get_system_default_handler
ls /opt/cpanel/ea-php82/root/etc/
ls /var/cpanel/users/<user>/php.ini 2>/dev/null
find /home/<user>/ -name ".user.ini" -o -name "php.ini" 2>/dev/null

If the handler is lsphp, cgi, or fpm, anything in .htaccess referencing php_value is dead weight. Remove it during cleanup; do not migrate it.

The fix

  1. For server-wide PHP settings, edit through MultiPHP INI Editor > Editor Mode > select the PHP version. Changes write to /opt/cpanel/ea-php<ver>/root/etc/php.ini. Reload the FPM pool for that version afterward: systemctl reload ea-php82-php-fpm.
  2. For per-account settings (a single account needs higher memory_limit), use MultiPHP INI Editor > Basic Mode > pick the user > edit the directive. cPanel writes a user-level .ini overlay that the right SAPI picks up automatically.
  3. For per-directory settings inside one account (a single WordPress install needs higher upload_max_filesize), place a .user.ini file in that directory:
    memory_limit = 512M
    upload_max_filesize = 64M
    post_max_size = 64M
    PHP re-reads .user.ini every user_ini.cache_ttl seconds (default 300). Do not expect instant effect.
  4. Remove php_value / php_admin_value lines from .htaccess files where the handler is not DSO or suPHP. They are doing nothing and confuse future operators.
  5. Validate: php -i | grep <directive> from CLI shows the server default, not the per-account override. To verify the override, write a one-line PHP file in the account’s docroot that echoes ini_get('memory_limit') and hit it through the web (then delete it).
  6. Document the source of truth per setting. The next ticket about “PHP did not pick up our change” is almost always “we edited the wrong layer.”

For environments where dozens of accounts have bespoke PHP tuning, Stack Harbor maintains a per-account override registry as part of cPanel/WHM management.