PHP Composer update “cannot allocate memory” error (using Laravel 4)

后端 未结 26 1423
天命终不由人
天命终不由人 2020-11-29 14:46

I just can\'t solve this one.

I\'m on Linode 1G RAM basic plan. Trying to install a package via Composer and it\'s not letting me. My memory limit is set to \"-1\" o

26条回答
  •  天命终不由人
    2020-11-29 15:33

    Here are the steps to fix the problem: (instant fast SWAP file allocation method used)

    Server SWAP Setup (Ubuntu 16.04 SWAP to Fix Out of Memory Errors)

    Check if you have swap already, memory and disk size:

        sudo swapon -s
        free -m
        df -h
    

    Make swap file: (change 1G to 4G if you want 4GB SWAP memory)

        sudo fallocate -l 1G /swapfile 
    

    Check swap file:

        ls -lh /swapfile
    

    Assign Swap File:

        sudo chmod 600 /swapfile
        sudo mkswap /swapfile
        sudo swapon /swapfile
    

    Check if swap OK, memory and disk size:

        sudo swapon -s
        free -m
        df -h
    

    Attach Swap File on System Restart:

        sudo nano /etc/fstab
            /swapfile   none    swap    sw    0   0
    

    Adjust Swap File Settings:

        cat /proc/sys/vm/swappiness
        cat /proc/sys/vm/vfs_cache_pressure
    
        sudo sysctl vm.swappiness=10
        sudo sysctl vm.vfs_cache_pressure=50
    
        sudo nano /etc/sysctl.conf
    

    SWAP File Priority: (0-100% => 0: Don't put to swap, 100: Put on SWAP and free the RAM)

            vm.swappiness=10
    

    Remove inode from cache: (100: system removes inode information from the cache too quickly)

            vm.vfs_cache_pressure = 50
    

提交回复
热议问题