Adjusting the PHP memory_limit setting
Introduction
The PHP setting memory_limit defines the maximum amount of memory available in bytes (or alternatively in kibibytes [K], mebibytes [M], or gibibytes [G]) available to PHP scripts. Limiting the memory ensures that PHP does not consume too much RAM, which could cause the available RAM to be exceeded or block other processes.
A high memory limit can lead to instability in your web applications. If you wish to adjust this value due to background processes, you can alternatively use our cron jobs in the Customer Center to run the tasks via SSH. We recommend a maximum value of 1 G. (GiB)
To adjust the PHP setting memory_limit, first log in to our Customer Center at account.creoline.com using your login credentials.
Use the navigation menu to select the server under Server for which you want to change the PHP settings. Then open the Plesk Control Panel via the Plesk Control Panel menu item.
If this menu item is not displayed on your server, you can find additional ways to log in in the article Logging In to the Plesk Control Panel.
Customizing Settings for a Single Domain
Once you’re logged in to Plesk, you can select the domain using the global search or the Subscriptions menu item.
Use the PHP Settings button to adjust the general PHP settings:
The memory_limit value defines the maximum amount of memory that PHP scripts are allowed to use. This value can be set freely and is specified in bytes.
After the settings are saved, the web server automatically reloads the configuration using a graceful restart, so that existing requests are paused rather than terminated.
Adjustment for All Domains
To adjust the PHP settings for all domains using a specific PHP version, you must edit the PHP configuration file php.ini. To do this, select PHP Settings from the Tools & Settings menu in the left sidebar.
Then click on the PHP version for which you want to adjust the settings globally.
The php.ini tab gives you access to the PHP configuration file:
Search for the term memory_limit in the text field and replace the specified value with the desired new value. The default setting in Plesk is 128M.
Then click the OK button to save the changes. The changes take effect immediately for all subscriptions that have the selected PHP version configured and have not been overridden using the custom PHP setting.
Error Message: Allowed memory size exhausted
PHP Fatal error:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 24576 bytes) The Allowed memory size exhausted error message appears as soon as the defined PHP memory limit is exceeded. Please note that there are different PHP runtime configurations for the web and CLI environments.
Adjusting the Memory Limit for a Single Call
If you need to temporarily adjust the memory limit for the CLI environment, you can use the -d parameter to override runtime configurations.
Example with PHP 8.4:
/opt/plesk/php/8.4/bin/php -d memory_limit=1G command.php Adjustment for All Calls
You can globally adjust the PHP runtime configuration for the CLI environment so that all future calls to PHP in the CLI environment use the adjusted configuration.
Paths to the PHP runtime configuration files in the CLI environment:
# PHP 7.4
/opt/plesk/php/7.4/etc/php.ini
# PHP 8.0
/opt/plesk/php/8.0/etc/php.ini
# PHP 8.1
/opt/plesk/php/8.1/etc/php.ini
# PHP 8.2
/opt/plesk/php/8.2/etc/php.ini
# PHP 8.3
/opt/plesk/php/8.3/etc/php.ini
# PHP 8.4
/opt/plesk/php/8.4/etc/php.ini Search for the following section in the respective php.ini file and adjust it as desired:
[...]
; Maximum amount of memory a script may consume
; http://php.net/memory-limit
memory_limit = 128M You do not need to restart PHP for the CLI environment. Changes take effect immediately.