“php--帮助”导致“PHP 内存耗尽” Ubuntu 上出现错误
PHP 致命错误:第 0 行未知中允许的内存大小为 262144 字节耗尽(试图分配 523800 字节)
“php5 --help”也发生同样的情况
我已经研究过这一点并读到我应该: 1) 增加 php.ini 中的内存限制 - 在 php.ini 的所有实例中均为 128MB - 应该足以运行 php cli help 2)使脚本内存效率更高 - 显然不适用于 --help
请帮忙,如果可以的话?
PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 523800 bytes) in Unknown on line 0
Same thing occurs with "php5 --help"
I have already researched this and read that I should:
1) increase the memory limit in php.ini - it's at 128MB in all instances of php.ini - should be enough to run php cli help
2) make the script more memory efficient - obviously doesn't apply to --help
Please help if you can ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
检查 PHP CLI 的 php.ini 文件 (/etc/php5/cli/php.ini)。
确保 memory_limit 声明设置了单位:
不是
它为我修复了。我希望它也适合你。
Check the php.ini file for PHP CLI (/etc/php5/cli/php.ini).
Make sure the memory_limit declaration has its units set:
not
It fixed it for me. I hope it works for you too.
我假设您最近安装了 Linux。我使用的是 Ubuntu,但任何 Debian(例如 Linux)发行版都会相似,其他发行版也不会有太多差异。
在 /etc/php5/ 中,我有以下配置目录:
您确定也更改了 CLI 内存限制吗?
如果您使用共享托管服务,则必须向他们的支持人员寻求帮助以更改限制,或者让他们找出为什么 php 即使在命令行上也消耗如此多的内存。
I am assuming you're on a recent Linux install. I'm using Ubuntu, but any Debian like Linux distribution will be similar and other distribution won't have a lot of differences either.
In /etc/php5/ I have the following configuration directories:
Are you sure you changed the CLI memory limit as well?
If you're on a shared hosting service, you will have to ask their support for help on changing the limits or have them find out why php is consuming so much memory even on the command line.
正文
表明 PHP 不认为它的内存限制是 128MB。也许您错过了一些 php.ini 文件?你能把你的 php.ini 发布到网上吗?
The text
Suggests that PHP doesn't think it's memory limit is 128MB. Perhaps you've missed some php.ini file? Could you maybe post your php.ini online?
ini 上的说明说使用 MB 是多么奇怪的事情,但这对我来说不起作用,标准的 apt-get install,我添加的唯一其他位是 APC。我不知道可能出了什么问题,谢天谢地,上面的一些评论建议只使用 M
在我看来似乎是一个错误,特别是考虑到 ini 上的说明。
ini 说这个
//脚本可能消耗的最大内存量(128MB)
但只有这个对我有用:/
228M
What a strange thing the instructions on the ini say to use MB but that wouldn't work for me, standard apt-get install, only other bit I added was APC. I couldn't figure what could be wrong, thankfully some comments above suggested just using the M
Seems like a bug IMO, especially given the instructions on the ini.
ini says this
//Maximum amount of memory a script may consume (128MB)
But only this worked for me :/
228M
我的 php.ini 文件中的值有 1024MB,但我仍然收到错误。我所做的修复是将其更改为 1024M,奇怪的是示例文本说 128MB
The value in my php.ini file had 1024MB and I was still getting the error. What I did to fix was changing it to 1024M, strange as the example text said 128MB
您可以运行 php -i 来获取 PHP 信息吗?您可能没有加载您期望的 php.ini 文件,并且内存限制要低得多。尽管如此,PHP CLI 使用 PHP 输出 CLI 帮助确实很奇怪。
更新您可能也无法运行
php -i
,但是php --ini
可能会至少向您展示什么(如果任何)INI 文件正在被使用。Can you run
php -i
to get the PHP info? It's possible that you're not loading the php.ini file you're expecting and the memory limit is much lower. Although, it's really bizarre that the PHP CLI would use PHP to output CLI help.Update You probably can't run
php -i
either, butphp --ini
might do the trick of at least showing you what (if any) INI file is being used.