PHP Configuration

PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.

There are some specific PHP directives that have a great impact on the website’s performance:

Directive Minimum Value Recommended Value
memory_limit 128M 256M
upload_max_filesize 10M depends on the needs of the client (64MB)
post_max_size 8M 20M
max_execution_time 60 300
max_input_vars 1 000 10 000

Please watch the video below to see how to update each value and what type of issues you can have if you don’t have enough resources allocated:

To ensure that file uploads work correctly, the post_max_size directive should be a little larger than the upload_max_filesize.

If you're not feeling confident with applying changes yourself or you don't have access to your WordPress files, you can contact your host provider's support with the following message:

Good time of the day!

I am in the process of setting up my website and I ran into an issue that seems to take root in WordPress PHP configuration according to Flothemes, my theme provider. Could you please implement what they suggest below in order to fix that? Thank you in advance.

Please, add the following lines of code at the end of wp-config.php:

@ini_set('memory_limit', '256M');
@ini_set('upload_max_size' , 64M');
@ini_set('post_max_size' , '20M');
@ini_set('max_execution_time' , '300');
@ini_set('max_input_vars', '10000');

If this doesn't seem to help or if you have any questions, please don't hesitate to reach out to Flothemes Support team directly via support@flothemes.com.

In case if you are sure that you can see to it on your own, proceed with the steps below.

1.1.1. <memory_limit>

This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. Note that to have no memory limit, set this directive to -1.

Issues: 

  1. blank screen
  2. website down

Solution:

In order to solve the  memory_limit issues, it is needed to increase its value. There are few methods through which this can be achieved:

  1. Edit the “wp-config.php” file. Add this line of code @ini_set( ‘memory_limit’, ‘512M’ );
  2. Change the value through the PHP settings via CPanel.
  3. Change the value directly in the “php.ini” file.

1.1.2. <upload_max_filesize>

This is the maximum size of an uploaded file. When an integer is used, the value is measured in bytes.

Issues: 

It will not be possible to upload heavy files. For example, if the default value is set to 8M, then it will not be possible to upload files that have a bigger weight.

Solution:

In order to solve the  upload_max_filesize issues, it is needed to increase its value. There are few methods through which this can be achieved:

  1. Edit the “wp-config.php” file. Add this line of code @ini_set( ‘upload_max_size’ , ‘256M’ );
  2. Change the value through the PHP settings via CPanel.
  3. Change the value directly in the “php.ini” file.

1.1.3. <post_max_size>

Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize.

1.1.4. <max_execution_time>

This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0.

1.1.5. <max_input_vars>

How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately).

Issues: 

  1. It may happen that all the changes that were made to a page, are not saved.
  2. It may happen that if on a single page there are used a lot of blocks, for example 30 blocks, then not all of them will be displayed.

Solution:

In order to solve the  max_input_vars issues, it is needed to increase its value. There are few methods through which this can be achieved:

  1. Edit the “wp-config.php” file. Add this line of code @ini_set(‘max_input_vars’, 20000);
  2. Change the value through the PHP settings via CPanel.
  3. Change the value directly in the “php.ini” file.

Final Check:

After adjusting the values, it’s needed to go to the public_html directory and add a new file called “phpinfo.php“. Inside, add the following line: <?phpinfo() ?>

Click on save and then access your website by adding /phpinfo.php at the end of your URL. You should have something like this: www.myurl/php.info

Then you can search and check if the values were updated accordingly.

If you have any other questions on the subject, feel free to let us know!

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us