Help us understand the problem. What is going on with this article?

Laravel で Cannot allocate memory がでたときの対策

More than 1 year has passed since last update.

VPS で、Laravel の次の操作を行うとエラーが出ました。

composer require league/flysystem-aws-s3-v3

エラーメッセージ

The following exception is caused by a lack of memory or swap, or not having swa
p configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-fai
led-errors for details


  [ErrorException]                                   
  proc_open(): fork failed - Cannot allocate memory

次のページに対策があります。
proc_open(): fork failed errors

1) Swap を確認

$ free -m
              total        used        free      shared  buff/cache   available
Mem:            983         159         705           3         119         691
Swap:             0           0           0

2) Swap を作成

$ sudo /bin/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, 1.0 GiB) copied, 13.3311 s, 80.5 MB/s
$ sudo /sbin/mkswap /var/swap.1
mkswap: /var/swap.1: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=7e8e5b8d-436b-49e0-a9e0-7998b24f8679
$ sudo /sbin/swapon /var/swap.1
swapon: /var/swap.1: insecure permissions 0644, 0600 suggested.

3) Swap を確認

$ free -m
              total        used        free      shared  buff/cache   available
Mem:            983         159          67           3         757         672
Swap:          1023           0        1023
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした