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

后端 未结 26 1369
天命终不由人
天命终不由人 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:21

    Easy, type this commands:

    rm -rf vendor/

    rm -rf composer.lock

    php composer install --prefer-dist

    Should work for low memory machines

    0 讨论(0)
  • 2020-11-29 15:22
    composer update
    
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    

    > mmap() failed: [12] Cannot allocate memory

    Update memory on Server and require '4G' Change 4GB Ram [try to change server type or add more ram]

    2 Files We need to edit


    on command

    # cd /var/www/html
    # nano .htaccess
    

    and edit "memory_limit 756M” to 4G


    Php ini on php 7.0

    # cd ~
    # php –-ini
    # sudo nano /etc/php-7.0.ini
    

    memory_limit = 128M to 4G

    #AWS #AMAZONLINUX #MAGENTO2 #PHP7.0

    0 讨论(0)
  • 2020-11-29 15:24

    I had a same issue on vagrant. I fixed it by allcate more memory.

     config.vm.provider :virtualbox do |vb|
          vb.customize ["modifyvm", :id, "--memory", "1024"]
     end
    
    0 讨论(0)
  • 2020-11-29 15:28

    you can use the following to check your free (swap) memory

    free -m
    
    total used free shared buffers cached
    
    Mem: 2048 357 1690 0 0 237
    -/+ buffers/cache: 119 1928
    Swap: 0 0 0
    

    To enable the swap you can use for example:

    /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
    /sbin/mkswap /var/swap.1
    /sbin/swapon /var/swap.1
    
    0 讨论(0)
  • 2020-11-29 15:28

    edit php.ini file and increase memory_limit value.

    memory_limit=1G

    will solve this issue.

    0 讨论(0)
  • 2020-11-29 15:30

    I tried by just deleting the vendor folder and composer.lock file and then i run the command composer clear-cache and then composer install. So it working without any error.

    0 讨论(0)
提交回复
热议问题