Composer内存不足 - 需要替代方法来增加PHP memory_limit

我正在尝试通过Composer在客户端的Magento 2上安装扩展程序,但我遇到了旧的 PHP内存不足错误。</ p>

我的客户端使用Bluehost托管,遗憾的是,我不能只是进入并更改php.ini中的memory_limit,因为它是只读的,并且他们的 cPanel MultiPHP INI编辑器不会影响SSH。 我的客户已与Bluehost联系,他们被告知Bluehost不允许更改SSH memory_limit,但是,我的客户端最近只需要安装一个不同的扩展,这需要增加memory_limit,但是他们自己做了 并且他们不记得他们使用了什么命令或他们编辑的文件。</ p>

我可以确认在服务器上正确安装了Composer,因为我可以运行命令 composer require path /到/延伸</代码>。 这只会导致内存不足错误。</ p>

运行命令 COMPOSER_MEMORY_LIMIT = -1 composer需要amasty / advanced-review </ code>会导致同样的错误:</ p>

  mmap()失败:[12]无法分配内存

mmap()失败:[12]无法分配内存

Fatal错误:内存不足(已分配809508864) (试图分配4096
bytes)在phar:/// opt / cpanel / composer / bin / composer / src / Composer
/ DependencyResolver / RuleSetGenerator.php第126行
</ code> </ pre>

任何人都有任何建议,我可以做些什么来使事情正常工作?</ p>
</ div>

展开原文

原文

I'm trying to install an extension on a client's Magento 2 via Composer, but I'm running into the old PHP out of memory error.

My client is hosted with Bluehost, which unfortunately means I can't just go in and change the memory_limit in php.ini, as it's read only, and their cPanel MultiPHP INI Editor doesn't affect SSH. My client has been in touch with Bluehost, and they were told Bluehost doesn't allow SSH memory_limit to be altered, HOWEVER, my client only recently had to install a different extension, which required the memory_limit to be increased, but they did it themselves and they can't remember what commands they used or the file they edited.

I can confirm Composer is installed properly on the server, since I can run the command composer require path/to/extension. This just results in the out of memory error.

Running the command COMPOSER_MEMORY_LIMIT=-1 composer require amasty/advanced-review results in the same error:

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory

Fatal error: Out of memory (allocated 809508864) (tried to allocate 4096
bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer
/DependencyResolver/RuleSetGenerator.php on line 126

Anyone have any suggestions as to what I can do to get things working properly?

dongxiao9583
dongxiao9583 对不起,我不清楚。我尝试了所有这些,但Bluehost的设置方式可防止内存限制被覆盖,除非通过cPanel的MultiPHPINI编辑器。好消息是,彼得解决了我的问题,这实际上不是我想的那样!
大约一年之前 回复
doulangbizhan5160
doulangbizhan5160 是否启用了user.ini文件?然后你可以像.htaccess一样创建一个新的.ini并覆盖它。一般来说,memory_limit是PHP_INI_ALL,这意味着你可以在任何地方设置它(.ini,ini_set和.htacess)。
大约一年之前 回复

1个回答



您没有遇到PHP内存限制。 如果错误消息的情况就是“允许N个字节的内存大小耗尽”。 失败的 mmap 电话表明您的身体状况不佳 内存。</ p>

升级主机或在具有更多内存的另一台计算机上执行依赖项更新。 为此</ p>


  1. 将composer.json和composer.lock复制到具有足够内存的计算机</ li>
  2. 运行 composer require amasty / </ li>
  3. 将更新的composer.json和composer.lock文件复制回Bluehost计算机</ li>高级审查 - 无脚本--ignore-platform-reqs </ code> >
  4. 在Bluehost计算机上运行 composer install </ code> </ li>
    </ ol>

    这是有效的,因为 composer install </ code>不能 不做任何复杂的依赖性解析,因此需要很少的内存。</ p>
    </ div>

展开原文

原文

You aren't running into the PHP memory limit. If that where the case the error message would be something like "Allowed memory size of N bytes exhausted". The failing mmap call suggests that you are running out of physical memory.

Either upgrade the host or do the dependency updates on another machine with more memory. To do so

  1. Copy composer.json and composer.lock to a machine with sufficient memory
  2. Run composer require amasty/advanced-review --no-scripts --ignore-platform-reqs on that machine
  3. Copy the updated composer.json and composer.lock files back to the Bluehost machine
  4. Run composer install on the Bluehost machine

This works because composer install doesn't do any complex dependency resolution and thus requires little memory.

doucu9677
doucu9677 我的天哪,你是对的,@彼得。 我之前遇到过一个PHP内存限制问题而且我是如此盲目,以至于我甚至没有注册我正在寻找一个完全不同的错误ðŸ¤|•你的解决方案有效 就像魔术一样,经过几个小时的头痛 - 沮丧和徘徊,我们让它发挥作用!
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐