美文网首页
PHP Fatal error: Allowed memory

PHP Fatal error: Allowed memory

作者: 周星星的学习笔记 | 来源:发表于2021-01-22 12:06 被阅读0次

    今天在使用composer安装扩展包的时候,报了如下的错误,记录一下解决的方法。

    一、报错如下

    /var/www/html/backend # composer require swooletw/laravel-swoole
    Warning from https://mirrors.aliyun.com/composer: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
    Using version ^2.6 for swooletw/laravel-swoole
    ./composer.json has been updated
    Loading composer repositories with package information
    Warning from https://mirrors.aliyun.com/composer: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2
    Updating dependencies (including require-dev)
    PHP Fatal error:  Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 129
    
    Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 129
    
    Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors./var/www/html/backend # 
    
    

    二、解决方法

    1.方法一:修改php.ini里面的memory_limit的值为 -1

    vim /etc/php.ini
    
    ; Maximum amount of memory a script may consume  
    ; http://php.net/memory-limit      
    memory_limit = -1
                                                                       
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                              
    ; Error handling and logging ;                                       
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  
    

    2.方法二:用如下命令安装

    php -d memory_limit=-1 /usr/local/bin/composer  require xxx/xxx
    #/usr/local/bin/composer是composer的安装路径
    
    执行结果如图

    三、备注

    1.本文参考:https://www.cnblogs.com/wjcms/p/13771343.html

    相关文章

      网友评论

          本文标题:PHP Fatal error: Allowed memory

          本文链接:https://www.haomeiwen.com/subject/efyszktx.html