How to Increase PHP Max Input Vars Limit?

03-Apr-2023

.

Admin

How to Increase PHP Max Input Vars Limit?

Hello Friends,

To increase the maximum input variables in PHP Apache Ubuntu, follow this tutorial. You will learn how to increase or change the max_input_vars directive on your Ubuntu server.

The max_input_vars directive is a PHP configuration setting that limits the number of form fields or variables that can be submitted through an HTTP POST request. This is a security measure to prevent malicious users from flooding your server with too much data. However, there may be cases where you need to increase this limit, such as when working with large forms or complex data structures. In this article, we will show you how to increase max_input_vars in PHP.

Step 1: Locate the php.ini file


The first step is to locate the php.ini file on your Ubuntu server. The default location of the file may vary depending on the PHP version you are using. You can use the phpinfo() function to find the location of the php.ini file.

Create a new PHP file called phpinfo.php in your web server’s document root directory with the following code:

<?php

phpinfo();

?>

Save the file and navigate to http://your-domain-name/phpinfo.php in your web browser. Look for the Loaded Configuration File row, which will show you the location of the php.ini file.

Step 2: Edit the php.ini file

Once you have located the php.ini file, open it in a text editor such as Nano or Vim.

bashCopy codesudo nano /etc/php/<version>/apache2/php.ini

Replace <version> with the PHP version you are using, for example, 7.4.

Step 3: Increase the max_input_vars directive

Search for the max_input_vars directive in the php.ini file. If you can’t find it, add the following line at the end of the file:

max_input_vars = 5000

This will increase the limit to 5000 variables. You can adjust the value to suit your needs.

Save the file and exit the text editor.

Step 4: Restart Apache

After editing the php.ini file, you need to restart the Apache web server for the changes to take effect. Run the following command:

sudo systemctl restart apache2

This will restart Apache and apply the new max_input_vars limit.

Step 5: Verify the new limit

To verify that the new max_input_vars limit has been set correctly, create a PHP file with the following code:

<?php

phpinfo();

?>

I hope it can help you...

#Ubuntu