Report this

What is the reason for this report?

How to fix the attached Error

Posted on March 17, 2021

Good day How to set PHP Time limit to 300 and and PHP Max input Vars to 1548



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello @waled ,

We do not see any attachments with this question. To answer your question about setting the PHP variables, it can be done via the php.ini file. Please refer to the below links for more information and detailed instructions. https://wpastra.com/docs/increase-php-time-limit-wordpress-sites/ https://themes.artbees.net/docs/increase-max-input-vars/

Hope this helps!

Cheers, Lalitha

Heya, @waled

I’ll do a brief summary of how to set the values.

you will need to modify the php.ini file. This file contains configuration directives that determine how PHP behaves. Here are the steps to accomplish this on your server.

Locate the php.ini File

The location of the php.ini file can vary depending on your server setup and operating system.

You can also find the php.ini path using the phpinfo() function:

Create a file named info.php in your web root directory:

sudo nano /var/www/html/info.php

Add the following code:

<?php phpinfo(); ?>

Open http://your-server-ip/info.php in your browser. Look for the Loaded Configuration File entry, which will show the path to your php.ini file.

Edit the php.ini File

Once you’ve located your php.ini file, follow these steps to edit it:

Open the php.ini file** in a text editor. For example, on Ubuntu, you can use nano:

sudo nano /etc/php/7.4/apache2/php.ini

Search for the max_execution_time and max_input_vars directives.

You can use CTRL + W in nano to search for these lines.

Modify the settings as required:

max_execution_time = 300 max_input_vars = 1548

  • max_execution_time**: This sets the maximum time in seconds that a PHP script is allowed to run. The default is usually 30 seconds. Setting it to 300 will allow scripts to execute for up to 5 minutes.

  • max_input_vars This controls how many input variables may be accepted. It is used to limit the number of POST variables or GET variables that can be sent. The default is typically 1000, but you can increase it to 1548.

Save and exit** the file.

-   In `nano`, press `CTRL + O`, then press `Enter` to save.
-   Press `CTRL + X` to exit.

Restart Your Web Server

After making changes to the php.ini file, you need to restart your web server to apply the changes.

For Apache

sudo service apache2 restart

For Nginx (using PHP-FPM)

sudo service php7.4-fpm restart sudo service nginx restart

After making these changes, you can verify them by checking your phpinfo() page again:

Regards

To set the PHP Time Limit and PHP Max Input Vars, you need to update your PHP configuration. Follow these steps:

1. Edit the PHP Configuration File

Locate and edit the appropriate php.ini file for your PHP setup. The file path depends on your PHP version and server setup:

  • For PHP-FPM:
sudo nano /etc/php/7.x/fpm/php.ini

For Apache with mod_php:

sudo nano /etc/php/7.x/apache2/php.ini

2. Modify Configuration Directives

Search for max_execution_time and max_input_vars in the file. If they are not present, add them.

max_execution_time = 300
max_input_vars = 1548
  • max_execution_time: Sets the maximum time in seconds a script is allowed to run.
  • max_input_vars: Limits the number of input variables (e.g., $_POST, $_GET) your script can handle.

3. Restart the Web Server

After making changes, restart your web server to apply them:

  • For PHP-FPM:
sudo systemctl restart php7.x-fpm
sudo systemctl restart nginx

For Apache:

sudo systemctl restart apache2

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.