How to override PHP settings
You can override most runtime php.ini values - such as memory_limit, max_execution_time and
the upload size limits - per application, without root access. To choose the PHP version or tune
PHP-FPM, see Configure PHP instead.
Override per application with a .user.ini file
Create a .user.ini file in your application's document root (for example public_html) and add one
setting per line:
memory_limit = 512M
max_execution_time = 300
post_max_size = 600M
upload_max_filesize = 512M
Most settings that PHP allows to be changed at the directory level can be overridden this way.
Note
PHP re-reads .user.ini only periodically - by default about every 5 minutes - so a change is
not always instant. Allow a few minutes before you test the result.
Override for the command line
A .user.ini file applies to web requests only. For a one-off command-line run, pass the value with
-d:
php -d memory_limit=512M your-script.php
Application-specific exceptions
Some applications set their own PHP values that take precedence over .user.ini for web requests.
Magento, for example, enforces limits through a PHP_VALUE line in its generated 50main.conf
(see Custom Nginx configuration):
fastcgi_param PHP_VALUE "memory_limit=2048M \n max_execution_time=18000";
If a .user.ini change has no effect on such a site, look for an override like this first.
Verify
Confirm the value actually applied with a temporary phpinfo() page:
<?php phpinfo();
Open it in your browser, search for the setting, then delete the file - never leave a
phpinfo() page on a live site.