How to Change PHP-FPM Settings

This guide will help you change PHP-related settings for FPM-enabled servers using the PHP Settings editor.

Cloudways Product avatar
Written by Cloudways Product
Updated over a week ago

Table of Contents

PHP-FPM has been available since version 5.3.x. The processor offers several settings that have a direct impact on the performance of PHP applications. This guide will help you change PHP-related settings for FPM-enabled servers using the PHP Settings editor.

How to Change PHP-FPM Settings

Here's how you can review and change PHP-FPM settings using the Cloudways Platform. If you are looking to enable the disabled PHP functions, you may review this article.

Step #1 — Navigate to Application Settings

Log in to your Cloudways Platform using your credentials.

  1. From the top menu bar, open Servers.

  2. Next, choose the server where your desired application is deployed.

    Classic Interface

    New Interface

  3. Click www (if you are using Classic Interface) or the globe icon (if you are using New Interface).

  4. Next, choose your application.

    Classic Interface

    New Interface

  5. Under Application Management, select Application Settings.

  6. Navigate to PHP FPM Settings.

    Classic Interface

    New Interface

Step #2 — Configure PHP-FPM Settings

You can manage PHP-related settings and directives through the PHP settings editor, accessed from the console in the PHP Settings tab in the Application Settings section under the Application Management area, as shown below.

Important

Please use this editor carefully and enter values in the proper format. You may risk breaking your application(s) with incorrect settings. The allowed directives are php_flag, php_admin_flag, php_value and php_admin_value. Make sure there is no semicolon (;) before the rules you have added, or else it will act as a comment.

  • php_flag is used to set boolean values for options. Allowed values for directives are On or Off. For example, php_flag[log_errors] = on

  • php_value is used for everything else other than the boolean (On and Off) parameters. For example: php_value[error_log] /some/dir/to/log/php_errors.log

  • Use php_admin_flag and php_admin_value if you do not wish to use php.ini, .htaccess or PHP call ‘ini_set’ (in the code) to override PHP settings.

Classic Interface

New Interface

Examples of PHP Directives

The following are a few examples of using PHP directives for changing settings for PHP applications.

Editing the Post Max Size

php_admin_value[post_max_size] = 25M

Set the Max Input Time

The maximum time allowed to a PHP script for parsing data can be changed easily. In the following example, the data parse time has been set to 300 seconds:

php_admin_value[max_input_time] = 300

Set the Max Execution Time

The max time a PHP script can take to process data (regardless of the size) can be easily changed. In the following example, this time has been set to 120 seconds:

php_admin_value[max_execution_time] = 120

Set the Memory Limit

The maximum memory size that a PHP script can allocate can be easily set. In the following example, the maximum memory size is set to 96 MB:

php_admin_value[memory_limit] = 96M

Change the Upload Max File Size

The maximum allowed file upload size for POST queries can be set through PHP directives. In the following example, this limit has been set to 25 MB.

php_admin_value[upload_max_filesize] = 25M

Enable PHP Errors

When enabled, this option allows the PHP scripts to log the errors in the server error log files:

php_admin_flag[log_errors] = on

Enable Display Errors

When enabled, this option allows errors to be displayed as part of the page response output. However, the common setting is OFF:

php_admin_flag[display_errors] = off

Set the Maximum File Upload Number

The maximum number of files that can be uploaded simultaneously through a PHP script can be easily set. In the following example, the number of files that can be uploaded is set to 20:

php_admin_value[max_file_uploads] = 20

Set the Maximum Number of Input Variables

Setting the maximum number of accepted input variables is a great way of preventing DDoS attacks. The list includes $_GET, $_POST & $_COOKIE. In the following example, the number of maximum allowed input variables is set to 3000:

php_admin_value[max_input_vars] = 3000

Set the Time Zone

You can set a specific date/timezone value for your PHP application:

php_admin_value[date.timezone] = Europe/Berlin

Important Notes

  • Remember to comment the rules that you have set in the .htaccess file for PHP directives (for instance, commands starting with php_value or php_flag). Otherwise, you’ll see an Internal Server Error or a blank page.

  • The settings mentioned in this KB article have precedence over the settings specified through PHP Server Level.

  • Any value set using ini_set in applications will override the configurations set using php_value and php_flag (without admin) directives used in the PHP-FPM settings.

  • Any value set using ini_set in application/php files will NOT be overridden by configurations set using php_admin_value and php_admin_flag.

  • The rewrite/redirect rules can be defined in the .htaccess file.

  • If you are unfamiliar with the PHP-FPM configurations or don’t want to use the advanced editor, we suggest you use server-level PHP settings (to configure basic and/or common PHP parameters.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?