dsgs8208 2019-07-18 08:32
浏览 1003
已采纳

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?

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥20 Python安装cvxpy库出问题
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥15 python天天向上类似问题,但没有清零
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题