2019-07-18 08:32
浏览 987

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

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?

图片转代码服务由CSDN问答提供 功能建议

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

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

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

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

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


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douyi1779 2019-07-18 08:58

    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.

    解决 无用
    打赏 举报

相关推荐 更多相似问题