PHP execution limits¶
There are several PHP configuration settings that may be responsible for prematurely halting a script. This is a frequent problem in many installations, especially when handling large file uploads. In the PHP site there is also a useful guide we recommend reading: Common pitfalls.
Some of these values are set during installation, in the PHP configuration pool you set up here:
The php.ini file¶
Additionally, some of these execution limit settings are maintained in the
php.ini file found on your server/computer. One thing to double-check is
that you are updating the correct
php.ini file (it is possible there is
more than one - one for your browser settings, and one for the command-line,
for example), and the location of these files is not consistent, as it depends
on a number of other factors.
Here are a couple of links to help you locate the file(s) on your system - you might want to double-check to see if there are other files as well:
Locating your web config file
The easiest way to locate your
php.ini web config file is to create a simple
PHP file with a single line of code in it, and view the output.
- Using a text editor, create a new file (name it however you want, e.g.
test.php), and make sure it ends with
- Put this single line of code in the file:
<?php phpinfo(); ?>
- Save the file, and then place it on your AtoM server, in the root AtoM
directory - if you have followed our recommended installation instructions, this
- Open the file via your web browser. For example, if you placed it into your
root folder, run
- In the page displayed, find the “Loaded Configuration File” row for your
Make sure to delete the phpinfo script above when it’s not needed, as the information displayed could be used by malicious persons to compromise your website security.
Locating your command-line config file
Run the following command via the command-line interface:
php -i | grep php.ini
The command-line will return the location of your PHP configuration file.
Adjusting PHP script execution limits¶
This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30.
max_execution_limit = 30
Limits the amount of memory a script may consume (in bytes [B], kilobytes [K], megabytes [M] or gigabytes [G]).
memory_limit = 128M
Please note that this memory limit is not related to the amount of system memory (RAM) available, but is an artificial limit imposed by PHP to avoid run-away scripts from consuming all system resources. This implies that adjusting the PHP configuration should be done before deciding whether adding more RAM to your system may be beneficial. This limit is especially important if you are trying to process digital objects because it is needed to allocate enough memory to process both the input and the output digital object. See the following table:
Size (MB) Megapixels 100 13 128 18 256 35 512 70
Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than
upload_max_filesize. Generally speaking,
memory_limitshould be larger than
post_max_size. When an integer is used without specifying the unit, the value is measured in bytes - shorthand (in bytes [B], kilobytes [K], megabytes [M] or gigabytes [G]) may also be used to specify bigger values.
post_max_size = 72M
The maximum size of an uploaded file. When an integer is used without specifying the unit, the value is measured in bytes - shorthand (in bytes [B], kilobytes [K], megabytes [M] or gigabytes [G]) may also be used to specify bigger values.
upload_max_filesize = 64M
There are more variables that can be adjusted as needed. We recommend reviewing the following resources:
After making configuration changes¶
If you do make changes to the PHP configuration poool and/or the
default settings, you should restart PHP-FPM after, and clear your application
caches and restart Memcached (if you’re using it as cache engine).
In Ubuntu 16.04 with PHP 7.0:
sudo systemctl restart php7.0-fpm php symfony cc
In Ubuntu 18.04 with PHP 7.2:
sudo systemctl restart php7.2-fpm php symfony cc
Optionally, to restart Memcached:
Ubuntu 16.04 or 18.04:
sudo systemctl restart memcached For more details on these commands, see: * :ref:`troubleshooting-restart-services` * :ref:`maintenance-clear-cache`
Learn more about AtoM command-line tasks and basic maintenance commands in the following slide deck:
New to using the unix command-line? If so, this slide deck will help you get started: