DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
cPanel

How to Enable Per-Site PHP Configuration and Find the Active php.ini

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For per-site PHP settings, use .user.ini with CGI, FastCGI, or PHP-FPM; use .htaccess only when PHP runs as an Apache module; and use a dedicated PHP-FPM pool when you administer the server and need stronger isolation. First confirm which PHP SAPI handles the website and which configuration it actually loads. A website generally cannot select a different complete php.ini after PHP has started.

Per-site settings are not the same as a separate php.ini

There are several different things people mean by “per-site PHP configuration”:

  • Global configuration: change the main configuration for every site using that PHP installation or handler.
  • Per-site overrides: change only selected directives for a domain or directory, using a mechanism supported by its PHP SAPI.
  • A dedicated PHP-FPM pool: give a site its own worker pool and administrator-controlled settings. This provides more isolation than a directory override, but does not necessarily mean the pool loads a separate complete php.ini.
  • A separate complete php.ini: choose the main configuration file at PHP startup. This is straightforward for a CLI command, but usually requires server-level control for a website.

Most site owners need per-site overrides, not a second complete configuration file. PHP’s available mechanisms differ by SAPI and permission level; see the PHP configuration changes documentation.

Identify the PHP SAPI serving the website

Do not assume that the PHP command you run over SSH matches the PHP handler serving your domain. CLI and web requests may use different PHP versions, installations, containers, or SAPIs. Put this temporary diagnostic script in the site’s document root and request it through a browser:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
header('Content-Type: text/plain');

echo 'SAPI: ', PHP_SAPI, PHP_EOL;
echo 'Loaded php.ini: ', php_ini_loaded_file() ?: '(none)', PHP_EOL;
echo 'Scanned .ini files: ', php_ini_scanned_files() ?: '(none)', PHP_EOL;

The SAPI helps choose the right per-site method: CGI, FastCGI, or FPM generally uses .user.ini; Apache module PHP may support PHP directives in .htaccess. If you use phpinfo() instead, remove the diagnostic page immediately afterward: it can expose server and configuration details.

Find the loaded php.ini and additional configuration files

From the command line

Run:

php --ini

Look for Loaded Configuration File, Scan for additional .ini files, and Additional .ini files parsed. For concise output, use:

php -r 'var_dump(PHP_SAPI, php_ini_loaded_file(), php_ini_scanned_files());'

These commands report the CLI PHP configuration. They do not establish which file the website uses; compare them with the browser-side diagnostic above.

How PHP selects configuration

PHP’s startup configuration depends on its SAPI, build, platform, and environment. The PHPRC environment variable can designate a configuration location, and CLI or CGI can accept the -c option. Apache module deployments may use PHPIniDir. After the main file is loaded, PHP may scan additional .ini files. The exact search locations vary, so runtime inspection is more reliable than assuming a universal path. PHP selects configuration during startup; for server-module PHP that generally happens when the web server starts, whereas CLI and CGI load configuration for each invocation. See PHP’s configuration-file documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Putting a file named php.ini in a public directory does not, by itself, make PHP use it. The active path and scanned files reported by the web request are the useful evidence.

Use .user.ini for CGI, FastCGI, and PHP-FPM

PHP’s per-directory user INI mechanism is intended for CGI/FastCGI SAPIs, including typical PHP-FPM deployments, subject to the host’s configuration. The default filename is .user.ini, but an administrator can change it with user_ini.filename; setting that directive to an empty value disables scanning. PHP accepts only directives whose changeability mode is INI_USER or INI_PERDIR in these files. Details are in the PHP per-user configuration documentation.

Create the file in the right directory

  1. Confirm the browser request uses CGI, FastCGI, or PHP-FPM.
  2. Check with your host that per-user INI scanning is enabled and note whether it uses a custom filename.
  3. Create .user.ini in the site’s document root, or in a subdirectory if the overrides should apply only to scripts there.
  4. Add only settings that are changeable in this context, using INI syntax rather than PHP code.
  5. Allow the user-INI cache interval to expire, or ask the administrator whether a supported worker reload is available.
  6. Verify the effective values with a browser request.

Example:

; /home/example/public_html/.user.ini
memory_limit = 256M
max_execution_time = 120
upload_max_filesize = 64M
post_max_size = 64M
display_errors = Off

PHP checks the directory containing the requested script and parent directories toward the document root. A file in one virtual host’s document root does not automatically govern another host. A shared parent directory can affect multiple sites if their scripts live beneath it. Scripts outside the document root may have more limited scanning behavior.

Check whether a directive can be changed

Do not assume every setting accepts a per-site override. PHP classifies directives as INI_USER, INI_PERDIR, INI_SYSTEM, or INI_ALL. Check the directive’s “Changeable” column in the PHP core INI directive reference or inspect it in phpinfo(). A host can also impose limits that prevent a customer from raising a value even when the directive is normally changeable at that level.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Values such as memory_limit, max_execution_time, max_input_vars, upload_max_filesize, post_max_size, max_file_uploads, and session.gc_maxlifetime are often requested as site overrides, but whether a particular host permits them depends on the directive mode and hosting policy.

Allow for the cache

PHP caches per-directory INI files. The interval is controlled by user_ini.cache_ttl and is commonly 300 seconds by default. Do not expect each request to reread an edited file immediately. On a server you administer, a supported PHP-FPM reload may refresh workers; shared-hosting customers may not have permission to restart them. Confirm when the host’s cache or worker configuration allows the new value to appear.

Use .htaccess only with Apache mod_php

If PHP is loaded as an Apache module and the server permits PHP directives in .htaccess, per-directory settings can look like this:

php_value memory_limit 256M
php_value max_execution_time 120
php_value upload_max_filesize 64M
php_value post_max_size 64M

This is not interchangeable with .user.ini. If Apache forwards PHP requests to PHP-FPM or another FastCGI backend, php_value may produce an “Invalid command” error or have no effect. Confirm the SAPI first; for FastCGI or FPM, use an allowed .user.ini override or the server’s pool configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a dedicated PHP-FPM pool when you administer the server

A separate pool is appropriate when domains need stronger separation, administrator-enforced settings, or distinct worker policies. A pool configuration can set values for its requests:

; Example FPM pool configuration
[example.com]
user = example
group = example
listen = /run/php/example.com.sock

php_value[memory_limit] = 256M
php_value[max_execution_time] = 120

; Administrative values cannot be overridden by the application:
php_admin_value[display_errors] = Off
php_admin_value[log_errors] = On
  1. Create or configure the pool using the server’s supported PHP-FPM configuration process.
  2. Point the domain’s virtual host or reverse proxy at that pool’s socket.
  3. Validate the PHP-FPM configuration using the validation command for your installed PHP package.
  4. Reload PHP-FPM using the service name and procedure for your operating system and package.
  5. Verify the effective settings through a browser request to the domain.

Pool-file locations, socket paths, service names, and reload commands differ by system; do not copy an example path as if it were universal. php_value sets a pool value, while php_admin_value makes the value administrator-enforced. A pool offers more control than .user.ini, but requires server access. A global php.ini is simpler to operate but can affect every site using that PHP handler.

Specify another php.ini for a command-line script

For CLI work, choose a file for a single invocation with -c:

php -c /path/to/site-php.ini script.php

Alternatively, set PHPRC for one command:

PHPRC=/path/to/site-php.ini php script.php

For subsequent commands in the shell session:

export PHPRC=/path/to/site-php.ini
php script.php

These examples configure that CLI process. They are not a dependable way for an ordinary shared-hosting website to select a different web php.ini. A web request has already started PHP before application code runs. Selecting a different main file for web traffic generally requires an administrator to configure the handler, virtual host, environment, PHP-FPM pool, or control panel. The -c and PHPRC startup mechanisms are described in the PHP configuration-file documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Set domain-level options in cPanel or Plesk

cPanel

On many cPanel hosts, open MultiPHP INI Editor, select the domain, choose its PHP version or domain context, edit the available settings, and save. The interface and editable directives depend on the host’s handler and configuration.

cPanel notes that account-level php.ini and .user.ini files may be found under the account’s home directory. With shell access, search for them with:

find /home/$username/ -name .user.ini
find /home/$username/ -name php.ini

Finding a file does not prove it is active for the domain; confirm the loaded file and values through a web request. See cPanel’s guidance on finding php.ini and .user.ini files. Server administrators should use cPanel-supported workflows for generated PHP-FPM configuration rather than manually editing implementation files; see cPanel’s PHP-FPM configuration locations and its EasyApache 4 PHP-FPM filesystem layout.

Plesk

Plesk generally exposes domain-specific options in the domain’s PHP settings page. Labels, available fields, configuration locations, and permissions depend on the Plesk version, operating system, and PHP handler. The panel may generate a .user.ini or handler-specific configuration rather than editing the system-wide php.ini. Use the domain controls where available and verify the effective values in a web request.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For handler and platform differences, consult Plesk’s configuration-file guidance, the Plesk guide to managing PHP settings, and the Plesk PHP settings documentation. If the setting or menu is unavailable, the administrator or provider may have restricted it.

Troubleshoot settings that do not take effect

  1. Confirm the request reaches the intended PHP version and domain. A domain can use a different handler, pool, or document root than expected.
  2. Inspect the web runtime. Check PHP_SAPI, php_ini_loaded_file(), and php_ini_scanned_files() from the browser, not only from SSH.
  3. Check changeability and policy. Confirm the directive’s mode and whether the host imposes a hard limit.
  4. Check the method and file location. Use .user.ini for CGI/FastCGI/FPM when enabled; use PHP’s .htaccess directives only with supported Apache module PHP. Confirm the filename, capitalization, placement, and file readability.
  5. Allow for reload and cache behavior. A cached .user.ini or unreloaded worker can make a correct edit appear ineffective.
  6. Look for another layer. A later scanned INI file, pool setting, control-panel policy, web server, proxy, application, or hosting quota can impose a different effective limit.

If php_value triggers an HTTP 500 error

Remove the new php_value lines to restore the site, then inspect the Apache error log. The handler may not be Apache module PHP, or that context may not permit the directive. Switch to the configuration method appropriate for the SAPI rather than leaving unsupported lines in .htaccess.

If uploads still fail

Inspect the effective PHP values in the web request:

<?php
var_dump([
    'upload_max_filesize' => ini_get('upload_max_filesize'),
    'post_max_size' => ini_get('post_max_size'),
    'memory_limit' => ini_get('memory_limit'),
    'max_file_uploads' => ini_get('max_file_uploads'),
]);

post_max_size must be sufficient for the entire request, not just one file. A web-server or proxy request-body limit, application validation, filesystem constraint, or hosting quota can still block an upload even when PHP’s values are adequate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If ini_set() changes only some values

ini_set() is a runtime override subject to the directive’s changeability mode and administrative restrictions. It cannot retroactively affect request parsing or other work PHP has already performed, and it is not a substitute for selecting the main configuration file.

Keep diagnostics and overrides safe in production

  • Delete temporary diagnostic scripts after use; do not leave a public phpinfo() page online.
  • Avoid putting credentials or other sensitive values in configuration files inside publicly downloadable paths. Use permissions and storage locations appropriate to the deployment.
  • Keep display_errors off in production and use logging for error diagnosis.
  • Do not rely on PHP configuration alone to secure filesystem access, filter requests, or impose all resource limits. Per-site overrides can weaken administrative protections if they permit a site to relax logging or limits.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.