Common PHP.ini Settings


Common PHP Settings

For many PHP applications, there are common values that need to be adjusted to best suit the needs of the application. Our Shared control panel offers quick and easy methods to modify these settings. In this article, we are going to discuss what settings are often needing to be updated.

  • Memory Limit
  • Post Max Size
  • Upload Max Filesize
  • Max Execution Time
  • Display Errors
  • Max Input Var

Memory Limit

The PHP memory limit is the value that controls the amount of memory per script that PHP is allowed to allocate. This is generally modified from the perspective of a maximum allocation. So not every PHP process will reserve the amount of RAM that you place in this value, but it is allowed to allocate that value “at most.” We see this issue commonly with CMS plugins, especially free ones, as they are not developed with optimization in mind.

Usage: memory_limit integer (Note: The default measurement of the integer is in bytes. You can add M after the number to specify the integer in megabytes.)

Post Max Size

The PHP post max size limit is a value that determines the maximum allowable size of a post request. This value is designed to limit the amount of data that can be sent to the server through your post requests. Post requests are used for input of content like forms (login and data gathering), but they can also be used for uploading content. WordPress, for example, uses the post max size value to determine size limits for is media upload process.
Usage: post_max_size integer (Note: The default measurement of the integer is in bytes. You can add M after the number to specify the integer in megabytes.)

Upload Max FileSize

The PHP Upload Max FileSize value is used to determine the maximum allowed size of an upload when using PHP. It is a good idea to ensure that the Post Max Size is equal to or larger than the upload max filesize setting.

Usage: upload_max_filesize = 10M (replace number with the filesize you would like to allow)

Display Errors

The PHP display errors is a value that is utilized to determine if the PHP environment will display errors from the environment level. You can configure your individual PHP pages to display errors using error_reporting or ini_set (error_reporting). This value will display the default error configuration on any page that encounters an exception and meets the error configuration level.

Usage: display_errors = On/Off

Max Execution Time

The PHP max execution time value is used to determine how long a process can run before being forcibly stopped. This value is used to restrict resource allocation to processes that are holding onto resources for too long when those resources could be put to better use for other processes. You can think of it like a timeout value.

Usage: max_execution_time integer (Note: The integer is measured in seconds)

Max Input Var

The max_input_vars directive defines how many input variables may be accepted. Use of this directive mitigates the possibility of denial of service attacks which use hash collisions. If more input variables are sent than are specified by the max_input_vars directive, an E_WARNING is presented, and further variables are truncated from the request.

Usage: max_input_vars integer