简体   繁体   English

无法增加 PHP 内存限制

[英]Unable to increase PHP Memory Limit

I am running into an issue with a project I am working with on my localhost, where I am unable to increase the PHP memory_limit setting.我在本地主机上使用的项目遇到问题,我无法增加 PHP memory_limit 设置。

I've tried increasing it directly in the php.ini config:我试过直接在php.ini配置中增加它:

memory_limit = 1024M

I've tried increasing it in the projects .htaccess file:我试过在项目.htaccess文件中增加它:

php_value memory_limit 1024M

I've tried increasing it directly in the function of the PHP controller:我已经尝试在 PHP 控制器的函数中直接增加它:

ini_set('memory_limit', '1024M');

Yet none of these actually increases the memory limit for the project, and echoing out phpinfo() confirms that the memory_limit has not been changed.然而,这些实际上都没有增加项目的内存限制,并且回显phpinfo()确认 memory_limit 没有改变。

I've checked the Loaded Configuration File setting in phpinfo() to ensure that I modified the correct php.ini file, and that no other additional config files are being parsed, that could conflict with this setting, but I am still unable to get the setting to increase.我检查了phpinfo()Loaded Configuration File设置,以确保我修改了正确的php.ini文件,并且没有解析其他可能与此设置冲突的其他配置文件,但我仍然无法获取要增加的设置。

Configuration File (php.ini) Path /etc/php5/apache2配置文件(php.ini)路径/etc/php5/apache2

Loaded Configuration File /etc/php5/apache2/php.ini加载的配置文件 /etc/php5/apache2/php.ini

Scan this dir for additional .ini files /etc/php5/apache2/conf.d扫描此目录以获取其他 .ini 文件 /etc/php5/apache2/conf.d

Additional .ini files parsed /etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-curl.ini, /etc/php5/apache2/conf.d/20-json.ini, /etc/php5/apache2/conf.d/20-memcached.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/20-readline.ini额外的 .ini 文件解析 /etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/ 20-curl.ini、/etc/php5/apache2/conf.d/20-json.ini、/etc/php5/apache2/conf.d/20-memcached.ini、/etc/php5/apache2/conf.d /20-mysql.ini、/etc/php5/apache2/conf.d/20-mysqli.ini、/etc/php5/apache2/conf.d/20-pdo_mysql.ini、/etc/php5/apache2/conf。 d/20-readline.ini

Any ideas from the community as to what else I could try?来自社区的关于我还可以尝试什么的任何想法? I am using PHP v5.5.9 .我正在使用PHP v5.5.9

So it turns out the memory limit was being increased properly, just not being reflected in phpinfo() .所以事实证明内存限制被正确增加,只是没有反映在phpinfo() 中 The reason it was not reflecting in the phpinfo() echo, is because I was making the memory increase in the controller, and then echoing phpinfo() from the view, so the increase was not being reflected in the view.它没有反映在phpinfo()回显中的原因是因为我在控制器中增加了内存,然后从视图中回显了 phpinfo(),所以增加没有反映在视图中。

Using ini_get() helped me trace the memory limit across the request.使用ini_get()帮助我跟踪整个请求的内存限制。

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

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