LoginSignup
32
36

More than 5 years have passed since last update.

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

Posted at

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
32
36
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
36