简体   繁体   English

在 XAMPP 中增加 php.ini 中的 max_input_var

[英]Increasing max_input_var in php.ini in XAMPP

I need to increase max_input_var in php.ini .我需要在php.ini增加max_input_var I am ruining xampp php version 5.6.3我正在破坏 xampp php 版本 5.6.3

I have several website folder on my local, and I am confused if I need to have php.ini file per website or its a single master file.我在本地有几个网站文件夹,如果我需要每个网站都有php.ini文件或其单个主文件,我很困惑。

I found php.ini file in xampp/php folder on localhost.我在本地主机上的 xampp/php 文件夹中找到了 php.ini 文件。 I edited and increased it there, restarted but php.info still says the default value 1000. I needed to be 2000 or more.我在那里编辑并增加了它,重新启动但 php.info 仍然说默认值 1000。我需要 2000 或更多。

I guess my next question is how should I do this from CPanel when the site is live?我想我的下一个问题是当网站上线时我应该如何从 CPanel 做到这一点?

I too had same issue/challenge for some months until recently I sorted it out.几个月来我也遇到了同样的问题/挑战,直到最近我才解决了。 I have search in the web through Google to fix this issue but with meager success.我通过谷歌在网络上搜索来解决这个问题,但收效甚微。 Because most of them are citing online servers and not local servers - XAMPP in this case.因为他们中的大多数都引用了在线服务器而不是本地服务器 - 在这种情况下是 XAMPP。

So, this is what I did to get my XAMPP working with the aforementioned settings causing issues for Menu system as well as Memory Limit on most PHP programmed websites.因此,这就是我为让 XAMPP 使用上述设置而导致的菜单系统问题以及大多数 PHP 编程网站上的内存限制所做的工作。 But for now, we are dealing with Max Input variable limit .但是现在,我们正在处理Max Input 变量 limit So, they are as follows:因此,它们如下所示:

  1. Go to your XAMPP folder > PHP Folder转到您的 XAMPP 文件夹 > PHP 文件夹
  2. In there look for 3 files: "php.ini", "php.ini-development", and "php.ini-production"在那里寻找 3 个文件: “php.ini”、 “php.ini-development”“php.ini-production”
  3. Open each files using any editor of your choice, for me is, Notepad++ and look or search for: max_input_vars = 1000 and increase it to whatever choice number, in my case "5000".使用您选择的任何编辑器打开每个文件,对我来说是 Notepad++ 并查找或搜索: max_input_vars = 1000并将其增加到任何选择编号,在我的情况下为“5000”。 Whatever thing you do on php.ini , do same on the other two files mentioned above.无论你在php.ini 上做什么,对上面提到的其他两个文件都做同样的事情。 Now notice on "php.ini-development", and "php.ini-production" the max_input_vars = 1000 are commented.现在注意“php.ini-development”“php.ini-production” max_input_vars = 1000的注释。 Uncomment it by removing the " ; " before max_input_vars = "your-new-number" .通过删除max_input_vars = "your-new-number"之前的" ; " 来取消注释。 Now save all of them.现在保存所有这些。

  4. If your XAMPP was running when your were doing all these changes, stop and restart it.如果您在进行所有这些更改时 XAMPP 正在运行,请停止并重新启动它。 Done!完毕! You are good to go.你已准备好出发。

These worked for me, I hope it will for you too and others who had this issues with their XAMPP local server.这些对我有用,我希望它也适用于你和其他在他们的 XAMPP 本地服务器上遇到这个问题的人。 I want to assume it will also work for WAMP too.我想假设它也适用于 WAMP。

Thanks and regards感谢致敬

PS: My XAMPP version is XAMPP 1.8.2 [PHP: 5.4.27] PS:我的 XAMPP 版本是 XAMPP 1.8.2 [PHP: 5.4.27]

For me such way was not works, at least on Linux, there was empty /lamp/php directory.对我来说,这种方式行不通,至少在 Linux 上,/lamp/php 目录是空的。

As superuser, find location of php.ini in your XAMPP directory (for me it was /opt/lamp/etc).作为超级用户,在您的 XAMPP 目录中找到 php.ini 的位置(对我来说是 /opt/lamp/etc)。 Open php.ini file and after ;php.ini Options (or somewhere else, upper is better)打开php.ini文件,然后在;php.ini选项(或其他地方,上层更好)

Add such line:添加这样的行:

max_input_vars = (that value, what you need).

Then save file and "Restart All" XAMPP server.然后保存文件并"Restart All" XAMPP 服务器。 It works for 5.6.19-0 XAMPP version.它适用于 5.6.19-0 XAMPP 版本。

Try this in you .htaccess file:在你的 .htaccess 文件中试试这个:

php_value max_input_vars 2000

Or add this function in php code:或者在php代码中添加这个函数:

ini_set('max_input_vars', 2000);

I placed it in .htaccess file: but I noticed that the after sometime php_value max_input_vars 2000 was removed by-itself.我把它放在 .htaccess 文件中:但我注意到一段时间后 php_value max_input_vars 2000 被自己删除了。


Also, in which php code I need to place "ini_set('max_input_vars', 2000);?另外,我需要在哪个 php 代码中放置 "ini_set('max_input_vars', 2000);?

in function.php, config.php, or php.ini在 function.php、config.php 或 php.ini 中

Its should be enough with ending php.ini file它应该足以结束 php.ini 文件

; ; How many GET/POST/COOKIE input variables may be accepted max_input_vars = 10000可以接受多少 GET/POST/COOKIE 输入变量 max_input_vars = 10000

The chosen answer is not a recommended approach nor the best practice as is correctly pointed out by its commenters as well as the .htaccess file documentation itself:正如其评论者以及.htaccess文件文档本身所正确指出的那样,所选择的答案既不是推荐的方法,也不是最佳实践:

The directives (lines) between "BEGIN WordPress" and "END WordPress" are dynamically generated, and should only be modified via WordPress filters. “BEGIN WordPress”和“END WordPress”之间的指令(行)是动态生成的,只能通过 WordPress 过滤器进行修改。 Any changes to the directives between these markers will be overwritten.这些标记之间的指令的任何更改都将被覆盖。

As the asker correctly indicated, the php.ini file in XAMPP is located in the xampp\\php directory.正如提问者正确指出的那样,XAMPP 中的php.ini文件位于xampp\\php目录中。

There is also a way to access and edit the underlying php.ini file from the XAMPP's interface by hitting the Apache server's Config button and then choosing php.ini menu:还有一种方法可以从 XAMPP 的界面访问和编辑底层php.ini文件,方法是点击 Apache 服务器的 Config 按钮,然后选择 php.ini 菜单:

在此处输入图片说明

Once the php.ini file opens up:一旦php.ini文件打开:

Search in there for the following stanza:在那里搜索以下节:

; How many GET/POST/COOKIE input variables may be accepted
; max_input_vars = 1000

Uncomment the max_input_vars variable and change it to the desired value, ie:取消对max_input_vars变量的注释并将其更改为所需的值,即:

; How many GET/POST/COOKIE input variables may be accepted
  max_input_vars = 2000

Restart the Apache server.重新启动 Apache 服务器。

Modifying it in this manner will result in the above system configs update properly reflected in the WP dashboard:以这种方式修改它会导致上述系统配置更新正确反映在 WP 仪表板中:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM