Skip to main content
How to Customize PHP Settings for Your Application

You can customize PHP settings for your Cloudways application with this step-by-step guide. Now, you can optimize performance with ease.

Emmad avatar
Written by Emmad
Updated over a week ago

Table of Contents

PHP plays a pivotal role in powering your web applications. At Cloudways, we understand that default PHP settings may not always align with the diverse needs of your projects. Hence, we empower you with the ability to customize PHP settings effortlessly through the Cloudways Platform.

This control becomes crucial when faced with scenarios like being unable to upload huge files on WordPress due to a low PHP memory limit or some plugins demanding more resources. This guide goes beyond the complexities of manual approaches and demonstrates how you can optimize and tailor PHP settings directly through the Cloudways Platform.

Whether you're building a small portfolio site, a WooCommerce store, or utilizing popular plugins like Divi, Elementor, and WP Bakery, our step-by-step guide will help you update the PHP settings of your applications according to your requirements.

What is PHP?

PHP, or Hypertext Preprocessor, is a scripting language vital for web development. It enables embedding dynamic features in websites and processing code on the server side. PHP's versatility makes it crucial for crafting interactive websites, from personal pages to complex systems like WordPress and Magento. It empowers developers to customize settings, adapting to diverse project requirements.

How to Customize PHP Settings for Your Application

First of all, please select your platform:

Cloudways Flexible

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, as shown below:

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

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.

Classic Interface

New Interface

Examples of PHP Directives

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

PHP Directive

Description

Example Setting

Post Max Size

Controls the maximum size of POST requests. In this example, the maximum POST size has been set to 25 MB.

php_admin_value[post_max_size] = 25M

Max Input Time

Limits the maximum time allowed to a PHP script for parsing data. In this example, the data parse time has been set to 300 seconds.

php_admin_value[max_input_time] = 300

Max Execution Time

Sets the maximum time a script can take to process data (regardless of the size). In this example, this time has been set to 120 seconds.

php_admin_value[max_execution_time] = 120

Memory Limit

Allocates the maximum memory for PHP scripts. In this example, the maximum memory size is set to 96 MB.

php_admin_value[memory_limit] = 96M

Upload Max File Size

Specifies the maximum file upload size for POST queries. In this example, this limit has been set to 25 MB.

php_admin_value[upload_max_filesize] = 25M

Enable PHP Errors

Enables logging of PHP errors in server logs. In this example, it is turned on.

php_admin_flag[log_errors] = on

Enable Display Errors

Controls whether errors are displayed as part of the page response output. In this example, it is turned off, which is a common setting.

php_admin_flag[display_errors] = off

Max File Upload Number

Sets the maximum number of simultaneous file uploads. In this example, the number of files that can be uploaded is set to 20.

php_admin_value[max_file_uploads] = 20

Max Number of Input Variables

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

php_admin_value[max_input_vars] = 3000

Timezone

Specifies the date/timezone for the PHP application. In this example, we have set this to Berlin.

php_admin_value[date.timezone] = Europe/Berlin

Important

  • Remember to comment out 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 the 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.

Cloudways Autonomous

You can manage PHP-related settings and directives through PHP Settings, as shown below:

Step #1 — Navigate to PHP Settings

Log in to your Cloudways Platform using your email address and password.

  1. From the side menu bar, choose Cloudways Autonomous and select My Applications.

  2. Next, choose your desired application.

  3. Navigate to Workflow/Tools.

  4. Next, select PHP Settings.

Step #2 — Configure PHP Settings

  1. You can manage PHP-related settings and update the values of PHP directives from here.

  2. Once done, click Apply.

Examples of PHP Directives

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

PHP Directive

Description

Memory Limit

Allocates the maximum memory for PHP scripts. In this example, the maximum memory size is set to 96 MB.

Execution Time

Sets the maximum time a script can take to process data (regardless of the size). In this example, this time has been set to 120 seconds.

Max Input Time

Limits the maximum time allowed to a PHP script for parsing data. In this example, the data parse time has been set to 300 seconds.

Post Max Size

Controls the maximum size of POST requests. In this example, the maximum POST size has been set to 25 MB.

Max Upload Size

Specifies the maximum file upload size for POST queries. In this example, this limit has been set to 25 MB.

Max Input Variables

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

PHP Timezone

Specifies the date/timezone for the PHP application. In this example, we have set this to Berlin. You can also click Auto Detect to detect your timezone automatically.

Important

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

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?