Information for: DEVELOPERS   PARTNERS

Configuring PHP settings

You can configure the PHP settings for each of your Cloud Platform environments. When viewing your applications, the version of PHP installed on your production environment is displayed on your application’s card.

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

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

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

    Location of the Configure option on the Cloud Platform interface

  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.

  4. Click Save.

Limits on memory configurations by subscription type

Depending on your subscription type, Cloud Platform may prohibit you from making certain changes to memory limits. Here is a list Acquia subscription types and their memory limits:

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. When viewing your applications, the Cloud Platform user interface displays the version of PHP installed on your production environment on your application’s card.

Which PHP version to use

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

Important

Acquia is ending support for PHP 7.2 in favor of PHP 7.3 on October 1, 2020. Subscribers must test and upgrade all non-production and production applications to PHP 7.3. For more information, see the Acquia Knowledge Base FAQ on Retiring PHP 7.2 in favor of PHP 7.3.

  • Acquia PHP 7.4: For use with Drupal 8 and greater websites. Some libraries available in Acquia PHP 7.3 may not yet be available in PHP 7.4 if they haven’t yet been updated by the PHP community for PHP 7.4 compatibility.
  • Acquia PHP 7.3 (default): For use with Drupal 8 and greater, and Drupal 7.68 websites. New environments will use PHP 7.3 by default.
  • Acquia PHP 7.2: Recommended for (and requires) version 7.61 or greater for Drupal 7 websites, or version 8.5 or greater for websites running Drupal 8. (Acquia will remove PHP 7.2 and force upgrade subscribers to PHP 7.3 on October 1, 2020. See the Software end-of-life schedule.)

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. Whenever you change your PHP version, 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 any of the PHP versions that Cloud Platform offers. 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 before changing your production environment.

Advanced PHP settings

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

Configuring any of the following values involves either using a setting’s slider to change 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 Cloud Platform.

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 doesn’t complete in in the max execution time, the process fails and sends an error. The 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 Cloud Platform. You can change the setting if 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 the PHP memory limit is 128 MB per process.

The default setting for PHP memory is adequate for most Drupal applications on Cloud Platform. You can change the setting if necessary. Increasing your PHP memory limit beyond 128 MB 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 a process ran out of memory.

If your application stops working and there is an Out of Memory error in the PHP error 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 512 MB per process.

Memory limits greater than 512 MB per process

Subscribers with Cloud Platform Plus, Cloud Platform Premium, and Cloud Platform Elite subscriptions can buy the Cloud Platform Performance Boost add-on for applications needing a PHP memory limit greater than 512 MB per process. The Performance Boost add-on can increase the PHP memory limit to a maximum of 1024 MB. Contact your Account Manager for more information.

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 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’re run, eliminating the time needed for reinterpretation on later requests.

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

All processes share the PHP OPcache, and its default size is 96 MB. Memory allocated to the PHP OPcache isn’t available for processes that are handling requests on your server, so there is a cost to making the cache size too large.

The minimum setting is 96 MB and the maximum setting is 512 MB.

OPcache interned strings buffer

The Interned Strings buffer is the amount of the PHP OPcache memory that’s 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 8 MB. If your OPcache is set to 96, this leaves 88 MB for normal OPcache usage. If you must increase the interned strings buffer over 16 MB, Acquia recommends increasing the OPcache by the same amount.

To set the Interned Strings buffer greater than 32 MB, contact Acquia Support.

APCu size

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

The maximum setting is 512 MB.

OPcache size and APCu size limits greater than 512 MB

OPcache size and APCu size are both dependent on the upper memory bound of the environment. The total of both of these values cannot exceed 512 MB.

Subscribers with Cloud Platform Plus, Cloud Platform Premium, and Cloud Platform Elite subscriptions can buy the Cloud Platform Performance Boost add-on for applications needing OPcache size and APCu size greater than 512 MB. The Performance Boost add-on can increase the OPcache size and APCu size to a maximum of 1024 MB. Contact your Account Manager for more information.

Maximum input variables

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

You may want to change this value if your application includes 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 Cloud Platform interface is 2500. If your application requires a greater value (or if you have an Cloud Platform Enterprise application), you can file a ticket for Acquia to set a greater value. Greater values can lead to security vulnerabilities, so Acquia recommends you don’t set the value to a number greater than 5000. As an alternative, you should consider redesigning your application’s forms to be smaller and less complex.

Maximum size of POST request

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