# Configuring PHP settings¶

You can configure the PHP settings for each of your Acquia Cloud environments.

To change an environment’s PHP settings, complete the following steps:

1. Sign in to Acquia Cloud, and then select the application that you want to configure.

2. Click the name of the environment that you want to configure, and then click Configure.

3. Use the PHP section to configure PHP for your application’s needs. Click one of the following available PHP settings for information about the item, including configuration options.

Acquia Cloud Enterprise and Acquia Cloud Free

Acquia Cloud Enterprise – The maximum input variables and maximum size of POST request are managed for you by Acquia, and are not available in the user interface. If you believe your application needs to have any of these values changed, contact Acquia Support.

Acquia Cloud Free – Your application runs on a shared server, and you cannot configure your PHP settings. To modify your PHP settings, upgrade your Acquia Cloud Free subscription to a paid Acquia Cloud Professional subscription.

4. Click Save.

## Configuring the PHP version¶

Your Drupal application runs on the PHP programming language. You can configure the version of PHP used by your application for each environment.

### Which PHP version to use¶

Acquia Cloud offers the following versions of PHP for your applications’ use:

• Acquia PHP 7.2 (default, recommended for 8.5+ and Drupal 7.61+) – The latest version of PHP 7.2, custom built for Acquia Cloud. Requires version 7.61 or greater for Drupal 7 websites, or version 8.5 or greater for Drupal 8 websites.
• Acquia PHP 7.1 – The latest version of PHP 7.1, custom built for Acquia Cloud.

Note

The Acquia Cloud pipelines feature is not fully compatible with PHP 7.2.

As a general principle, use the latest available version of PHP. Each new version of PHP includes both enhancements and bug fixes that can improve the performance and security of your Drupal application. However, you may be using custom or contributed Drupal modules that depend on an earlier version of PHP. Although this is not common, whenever you change your PHP version, you should always do so first on your Development or Stage environment—not on your Production environment—and test it to ensure that there are no compatibility issues.

### Working with different PHP versions on different environments¶

Most PHP code should work fine on either PHP 7.1 or PHP 7.2. Some of your code may work on one version of PHP, but not with another version. If you plan on switching to a different version of PHP, do so first on your Dev or Stage environment and test it thoroughly before changing your production environment.

The following settings are for advanced users. For most applications, you should leave them at their default settings. Change them only if you are advised to do so by Acquia Support, or if you are confident that you know what you are doing. If you have Acquia Cloud Free, your application runs on a shared server, and you cannot configure your PHP settings. You can, however, upgrade your Acquia Cloud Free subscription to a paid Acquia Cloud subscription.

Configuring any of the following values involves either using a setting’s slider to modify the value in its field, or by directly entering values in the field. To return any of the following settings to their original value, click the Reset link by the value, and then click Save.

Diagnosing and fixing PHP errors

If you believe your application is experiencing PHP errors, see PHP Error logs. To correct PHP memory issues, see Finding/Resolving Memory Related PHP errors in Acquia Cloud.

### Configuring max execution time¶

By modifying the Max execution time field, you can configure the maximum amount of time any PHP process can take. If a PHP process does not complete in this amount of time, it fails and sends an error. This time limit helps to prevent PHP processes from becoming stuck and unavailable to serve new requests.

The default setting for PHP maximum execution time (300 seconds, or 5 minutes) is adequate for most Drupal applications on Acquia Cloud, and you should change it only when necessary.

The danger of allowing longer PHP maximum execution times is that individual page loads can occupy process slots for long periods of time, blocking other processes from using them.

### Configuring PHP memory limit¶

The PHP memory limit is the maximum amount of RAM (random access memory) that a single PHP process can use. The memory used by the MySQL client counts against the PHP memory limit. The default setting for this value is 128MB per process.

The default setting for PHP memory is adequate for most Drupal applications on Acquia Cloud, and you should only change it when necessary. Increasing your PHP memory limit beyond 128MB on any one environment may reduce the number of PHP processes available to handle requests across all environments on your server. Your Drupal application can run out of PHP memory. If it does, you’ll see an entry in the PHP error log stating that a process ran out of memory.

If your application stops working and there is an Out of Memory error in the PHP log, increase the PHP memory in small increments until your application is working again, and then add a safety margin of additional memory. The maximum setting is 512MB per process.

Memory limits greater than 512MB per process

Customers with Acquia Cloud Plus, Acquia Cloud Premium and Acquia Cloud Elite subscriptions can purchase the Acquia Cloud Performance Boost add-on for applications needing a PHP memory limit greater than 512MB per process. Contact your Account Manager for more information.

Customers with other types of subscriptions that need a PHP memory limit greater than 512MB per process must contact Acquia Support.

If the Out of Memory error was caused by a one-time set of conditions (for example, enabling a large set of modules), reduce the PHP memory setting after the event. If you leave the PHP memory setting too high, you won’t be able to run more than a few PHP processes on a machine without running out of RAM.

### Configuring OPcache size¶

Using an OPcache significantly improves PHP performance. Since PHP is an interpreted programming language, each time a PHP script is called, it has to be reinterpreted. An opcode cache saves these scripts as machine code in memory the first time they are run, eliminating the time needed for reinterpretation on subsequent requests.

Acquia’s test results indicate that using an opcode cache generally offers a three-fold to four-fold increase in performance. To improve application performance, Acquia Cloud implements opcode caching by default on all applications, using OPcache.

The PHP OPcache is shared among all processes, and its default size is 96MB. Memory allocated to the PHP OPcache is not available for processes that are handling requests on your server, so there is a cost to making the cache size too large.

### OPcache interned strings buffer¶

The Interned Strings buffer is the amount of the PHP OPcache memory that is reserved for storing strings in OPcache. The amount of memory allocated to the Interned Strings Buffer will reduce the total amount of memory available for PHP OPcache.

The default setting is 8MB. If your OPcache is set to 96, this leaves 88MB for normal OPcache usage. If you need to increase the interned strings buffer over 16MB, Acquia recommends increasing the OPcache by the same amount.

### APCu size¶

This sets the amount of memory allocated to APC User Cache (APCu). This is a smaller cache than PHP OPcache, and most applications will run well with the default value (32MB). Drupal 8 makes more use of the APCu cache as a local, short-term cache than previous versions of Drupal did.

APC cache limits greater than 128MB

Customers with Acquia Cloud Plus, Acquia Cloud Premium and Acquia Cloud Elite subscriptions can purchase the Acquia Cloud Performance Boost add-on for applications needing APCu allocations greater than 128MB. Contact your Account Manager for more information.

Customers with other types of subscriptions that need an APCu allocation greater than 128MB must contact Acquia Support..

### Maximum input variables¶

This information in this section applies only to Acquia Cloud Professional subscribers.

You can set the maximum number of input variables that can be accepted. This limit (the PHP max_input_vars setting) is applied separately to $_GET, $_POST, and \$_COOKIE inputs. The default value is 1000.

You might want to change this value if your application includes very large or complex form inputs and you are getting PHP warnings about input variables exceeding the limit. The default value is 1000. The highest value you can set in the Acquia Cloud interface is 2500. If your application requires a higher value (or if you have an Acquia Cloud Enterprise application), you can file a ticket for Acquia to set a higher value. However, higher values can lead to security vulnerabilities, so we recommend that you do not set the value higher than 5000. As an alternative, you should consider redesigning your application’s forms to be smaller and less complex.

### Maximum size of POST request¶

This information in this section applies only to Acquia Cloud Professional subscribers.

You can set the maximum size of a POST that can be accepted (the PHP post_max_size setting). This value affects the maximum size of file uploads on your application. Generally, this value should be smaller than the PHP memory limit. The default value is 256MB. Larger sized POSTs are more susceptible to failure.

Still need assistance? Contact Acquia Support