今天在生产环境下进行composer 更新的时候出现如下错误:PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed - Cannot allocate memory' in phar
一查原来是swap不够了。Link: https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors
然后按照教程,开始前free -m是这样的
ubuntu@ip-172-31-4-204:~$ free -m
total used free shared buff/cache available
Mem: 990 279 467 20 243 528
Swap: 0 0 0
一顿sudo操作:
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
/sbin/swapon /var/swap.1
在看free -m
ubuntu@ip-172-31-4-204:~$ free -m
total used free shared buff/cache available
Mem: 990 279 69 20 641 527
Swap: 1023 0 1023
在运行composer install就没错误了。