Home  >  Article  >  Development Tools  >  How to solve the error proc_open(): fork failed - Cannot allocate memory after installing composer

How to solve the error proc_open(): fork failed - Cannot allocate memory after installing composer

藏色散人
藏色散人forward
2021-03-04 11:40:222492browse

The following tutorial column of composer will introduce you to the solution to the error proc_open(): fork failed - Cannot allocate memory after installing composer. I hope it will be helpful to friends in need!

How to solve the error proc_open(): fork failed - Cannot allocate memory after installing composer

After installing composer, the error proc_open(): fork failed - Cannot allocate memory

1. Problem Description:

When using composer to deploy the yii project on the Linux server, "proc_open(): fork failed - Cannot allocate memory"

is the prompt" Prompt "Insufficient Memory", we can solve this problem by creating a swap partition.

2. Solution:

  • First run free -m to see how much space there is
  • in the command line environment in sequence Run the following three commands
dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
mkswap /var/swap.1
swapon /var/swap.1
  • Example: [The following is the result of my running on the server]
dd if=/dev/zero of=/var/swap.1 bs=1M count=1024   //第一条指令
1024+0 records in    //这个是返回的内容
1024+0 records out   //这个是返回的内容
1073741824 bytes (1.1 GB) copied, 10.0607 s, 107 MB/s    //这个是返回的内容
mkswap /var/swap.1   //第二条指令
Setting up swapspace version 1, size = 1048572 KiB   //这个是返回的内容
no label, UUID=f6280c41-21b4-4039-bc3e-c26284b47b0c   //这个是返回的内容
swapon /var/swap.1  //第三条指令
swapon: /var/swap.1: insecure permissions 0644, 0600 suggested.   //这个是返回的内容
  • Explanation:
dd 从/dev/zero设备复制出一个1G大小的文件/var/swap.1

mkswap 格式化/var/swap.1

swapon 将swap分区挂在到文件系统

然后输入free -m 查看内存使用量信息
  • Finally, execute composer update again and it will be successful.

The above is the detailed content of How to solve the error proc_open(): fork failed - Cannot allocate memory after installing composer. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete