This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

Introducing Cloudways Community Forum. Start Discussions and Get Instant Help From Cloudways Community. JOIN NOW
Enhance your managed hosting experience with fast performance, 24x7 support and managed security. Start for Free

How to Change PHP-FPM SettingsDecember 11, 2018

 

In this KB

  • How to Change PHP Settings
  • Examples of PHP directives
  • Important notes

 

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

Step 1: Go to Application Management

Log into the Cloudways Platform with your credentials. Click on Applications in the top menu bar and then select your target application from the list.

Application Management

Step 2: Configure PHP-FPM Settings

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

PHP Settings

Note: 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.

  • 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.

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

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:

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:

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:

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.

Enable PHP Errors

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

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:

Set the Maximum File Upload Number

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

Set the Maximum Number of Input Variables

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

Set the Time Zone

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

Important Notes:

  • Remember to comment out 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 not familiar with the PHP-FPM configurations or don’t want to use the advanced editor, we suggest you to use server-level PHP settings (to configure basic and/or common php parameters.
Please insert Content
Have Questions? Ask From Our Helpful Community

4 Responses

  1. Marijn Achterkamp says:

    Will the normal htaccess redirect keep working with FPM?

    • Cloudways says:

      Yes, the normal redirect rules will still keep on working with FPM.

      Regards,
      Cloudways Team

  2. Mitch says:

    This might go wrong:
    php_value[php_post_max_size] = 25M

    Instead, use this::
    php_value[post_max_size] = 25M

    • Joonas says:

      Yep, the php_value[php_post_max_size] doesn’t even work. You have to use php_value[post_max_size] instead.

Do you still need help?

Our Technical Support team is always at work.