PHP memory_limit 锁定为 256MB?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9519194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP memory_limit locked to 256MB?
提问by dynamic
I am trying to set memory_limit to 512M, but it's locekd to 256M.
我试图将 memory_limit 设置为 512M,但它的 locekd 为 256M。
ini_set('memory_limit','512M');
ini_get('memory_limit'); //> Returns: 256M
I have full control on my server. (it's a dedicated)
我可以完全控制我的服务器。(这是一个专用)
Please note that everything under 512M works.
请注意,512M 以下的所有内容都有效。
ini_set('memory_limit','16M');
ini_get('memory_limit'); //> Returns: 16M
Solution
解决方案
I found out why. in php.ini I had memory_limit = 256M
. Maybe this is considered as an upper limit
我发现了原因。在 php.ini 我有memory_limit = 256M
。也许这被认为是上限
采纳答案by Ing
3 possibles I can think of / find:
我能想到/发现的 3 种可能:
Prior to PHP 5.2.1, in order to use this directive it had to be enabled at compile time by using --enable-memory-limit in the configure line.
在 PHP 5.2.1 之前,为了使用这个指令,它必须在编译时通过在配置行中使用 --enable-memory-limit 来启用。
OR
或者
The issue detailed here: ini_set("memory_limit") in PHP 5.3.3 is not working at all
此处详述的问题:PHP 5.3.3 中的 ini_set("memory_limit") 根本不起作用
OR
或者
ini_set is disabled
ini_set 被禁用
回答by Stephen Senkomago Musoke
You can also try to change the memory_limit using either a php.ini or .htaccess file
您还可以尝试使用 php.ini 或 .htaccess 文件更改 memory_limit
php.ini
配置文件
memory_limit = 512M;
.htaccess
.htaccess
php_value memory_limit 512M
回答by Paul
A bit late in the day but editing the php.ini file didn't work for php 7.1 using Mac OS 10.11.6. I still kept on getting the 'PHP Fatal error: Allowed memory size of....' which from its value showed the memory setting was not updating after starting apache.
当天有点晚,但编辑 php.ini 文件对使用 Mac OS 10.11.6 的 php 7.1 不起作用。我仍然不断收到“PHP 致命错误:允许的内存大小为....”,从它的值显示内存设置在启动 apache 后没有更新。
So instead of editing the file.
因此,而不是编辑文件。
/usr/local/php5/lib/php.ini
I found changing the following file fixed this issue.
我发现更改以下文件可以解决此问题。
/usr/local/php5/php.d/99-liip-developer.ini
This file was actually replacing the values set in the initial php.ini file. Again making the following changes to the line...
该文件实际上替换了初始 php.ini 文件中设置的值。再次对该行进行以下更改...
memory_limit = 256M
to
到
memory_limit = 1024M
And restarting apache.
并重新启动apache。
sudo /usr/sbin/apachectl restart
回答by Oleksiy Muzalyev
I noticed that on my Mac (OS X El Capitan) and the new PHP 7.0.0, I cannot change memory_limit via php.ini
我注意到在我的 Mac (OS X El Capitan) 和新的 PHP 7.0.0 上,我无法通过 php.ini 更改 memory_limit
But I can change it via /etc/apache2/httpd.conf by adding the line in the end:
但是我可以通过 /etc/apache2/httpd.conf 通过在最后添加以下行来更改它:
php_value memory_limit 1024M
php_value memory_limit 1024M
and restarting apache server:
并重新启动apache服务器:
sudo apachectl restart
须藤apachectl重启
And it is the correct php.ini , I can change other settings via it.
它是正确的 php.ini ,我可以通过它更改其他设置。
回答by musse1
You could check in your php.ini config file at the directive called "disable_functions". Check if ini_set is disabled.
您可以在名为“disable_functions”的指令处检查您的 php.ini 配置文件。检查 ini_set 是否被禁用。
Also if safe_mode is enabled such option may not be overriden.
此外,如果启用了 safe_mode,则可能不会覆盖此类选项。
回答by dynamic
I found out why. in php.ini I had memory_limit = 256M
. Maybe this is considered as an upper limit.
我发现了原因。在 php.ini 我有memory_limit = 256M
。也许这被认为是上限。
I rised it to my need.
我把它提升到我的需要。