composer 报错 PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate...

今天在使用composer安装Laravel时报错,如下:

PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.%


报错截图

超出PHP配置内存导致的错误。

可以运行以下命令查看当前php配置允许内存大小

php -r "echo ini_get('memory_limit').PHP_EOL;"


输出:128M;

意思是当前php允许最大使用内存为128M;

方法1: 

修改php.ini配置,修改里面的 memory_limit = -1,(-1是不限制)永久增加php内存配置。修改完成后,重启服务。

方法2:

设置命令运行时不限制内存大小

php -d memory_limit=-1 /usr/local/bin/composer  your_shell


推荐第二种

你可能感兴趣的:(composer 报错 PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate...)