Почему при установке Laravel 5.7 на Ubuntu произошел сбой форка - ошибка не может быть выделена при ошибке - PullRequest
1 голос
/ 14 июня 2019

При установке приложения Laravel 5.7 на убунуту 16 под LEMP / ASW я получил ошибку:

$ composer install
Cannot create cache directory /home/ubuntu/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/ubuntu/.composer/cache/files/, or directory is not writable. Proceeding without cache
Loading composer repositories with package information
Updating dependencies (including require-dev)

PHP Fatal error:  Uncaught ErrorException: proc_open(): fork failed - Cannot allocate memory in /usr/share/php/Symfony/Component/Console/Application.php:943
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', '/usr/share/php/...', 943, Array)
#1 /usr/share/php/Symfony/Component/Console/Application.php(943): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 /usr/share/php/Symfony/Component/Console/Application.php(751): Symfony\Component\Console\Application->getSttyColumns()
#3 /usr/share/php/Symfony/Component/Console/Application.php(712): Symfony\Component\Console\Application->getTerminalDimensions()
#4 /usr/share/php/Symfony/Component/Console/Application.php(645): Symfony\Component\Console\Application->getTerminalWidth()
#5 /usr/share/php/Symfony/Component/Console/Application.php(127): Symfony\Component\Console\Application->renderException(Object(RuntimeException), Object(Symfony\Component\Console\Output\StreamOutput))
#6 /usr/share/php/Composer/Console/Application. in /usr/share/php/Symfony/Component/Console/Application.php on line 943

Fatal error: Uncaught ErrorException: proc_open(): fork failed - Cannot allocate memory in /usr/share/php/Symfony/Component/Console/Application.php:943
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', '/usr/share/php/...', 943, Array)
#1 /usr/share/php/Symfony/Component/Console/Application.php(943): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 /usr/share/php/Symfony/Component/Console/Application.php(751): Symfony\Component\Console\Application->getSttyColumns()
#3 /usr/share/php/Symfony/Component/Console/Application.php(712): Symfony\Component\Console\Application->getTerminalDimensions()
#4 /usr/share/php/Symfony/Component/Console/Application.php(645): Symfony\Component\Console\Application->getTerminalWidth()
#5 /usr/share/php/Symfony/Component/Console/Application.php(127): Symfony\Component\Console\Application->renderException(Object(RuntimeException), Object(Symfony\Component\Console\Output\StreamOutput))
#6 /usr/share/php/Composer/Console/Application. in /usr/share/php/Symfony/Component/Console/Application.php on line 943

Я полагаю, это ошибка нехватки памяти

phpinfo показывает мне:

memory_limit    2056M   2056M
$ uname -a
Linux serge 4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux


$ free
              total        used        free      shared  buff/cache   available
Mem:        1014384      224744      454504       13848      335136      611300
Swap:       1048572           0     1048572

$ whoami
ubuntu

Я думаю, что этой памяти должно быть достаточно для моего приложения, но почему ошибка? На какие параметры стоит обратить внимание?

Изменено: Я проверил параметры как в /etc/php/7.2/fpm/php.ini, так и в файлах /etc/php/7.2/cli/php.ini:

memory_limit = 2056M
max_execution_time = 3300 
max_input_time = 240 

upload_max_filesize = 200M 
post_max_size = 200M
output_buffering = on 
short_open_tag = On  

Модифицировано # 2: Я все еще ищу решение. Я попытался установить другой проект, в котором меньше установленных пакетов (на самом деле это приложение laravel / vuejs), но я получил ту же ошибку:

# composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing symfony/polyfill-ctype (v1.11.0)
    Downloading: 100%         
The following exception is caused by a lack of memory and not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

PHP Fatal error:  Uncaught ErrorException: proc_open(): fork failed - Cannot allocate memory in /usr/share/php/Symfony/Component/Console/Application.php:943
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', '/usr/share/php/...', 943, Array)
#1 /usr/share/php/Symfony/Component/Console/Application.php(943): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 /usr/share/php/Symfony/Component/Console/Application.php(751): Symfony\Component\Console\Application->getSttyColumns()
#3 /usr/share/php/Symfony/Component/Console/Application.php(712): Symfony\Component\Console\Application->getTerminalDimensions()
#4 /usr/share/php/Symfony/Component/Console/Application.php(645): Symfony\Component\Console\Application->getTerminalWidth()
#5 /usr/share/php/Symfony/Component/Console/Application.php(127): Symfony\Component\Console\Application->renderException(Object(ErrorException), Object(Symfony\Component\Console\Output\StreamOutput))
#6 /usr/share/php/Composer/Console/Application.ph in /usr/share/php/Symfony/Component/Console/Application.php on line 943

Fatal error: Uncaught ErrorException: proc_open(): fork failed - Cannot allocate memory in /usr/share/php/Symfony/Component/Console/Application.php:943
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', '/usr/share/php/...', 943, Array)
#1 /usr/share/php/Symfony/Component/Console/Application.php(943): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 /usr/share/php/Symfony/Component/Console/Application.php(751): Symfony\Component\Console\Application->getSttyColumns()
#3 /usr/share/php/Symfony/Component/Console/Application.php(712): Symfony\Component\Console\Application->getTerminalDimensions()
#4 /usr/share/php/Symfony/Component/Console/Application.php(645): Symfony\Component\Console\Application->getTerminalWidth()
#5 /usr/share/php/Symfony/Component/Console/Application.php(127): Symfony\Component\Console\Application->renderException(Object(ErrorException), Object(Symfony\Component\Console\Output\StreamOutput))
#6 /usr/share/php/Composer/Console/Application.ph in /usr/share/php/Symfony/Component/Console/Application.php on line 943

composer.json этого проекта:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "fzaninotto/faker": "^1.8",
        "intervention/image": "^2.4",
        "laracasts/utilities": "^3.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "orangehill/iseed": "^2.6",
        "pusher/pusher-php-server": "^3.4",
        "tymon/jwt-auth": "^1.0.0",
        "wboyz/laravel-enum": "^0.2.1",
        "zizaco/entrust": "^1.9"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "beyondcode/laravel-query-detector": "^1.0",
        "filp/whoops": "^2.0",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0",
        "xethron/migrations-generator": "^2.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

Также странно то, что я установил оба приложения в Ubuntu 18 под Digital Ocean с одинаковым количеством памяти. на AWS Ubuntu 16:

# lsb_release -d; uname -r; uname -i
Description:    Ubuntu 16.04.6 LTS
4.4.0-1084-aws
x86_64

# free
              total        used        free      shared  buff/cache   available
Mem:        1014384       48724      856564         700      109096      824368
Swap:       1048572      264404      784168

в Digital Ocean Ubuntu 18 (оба приложения работают нормально):

# lsb_release -d; uname -r; uname -i
Description:    Ubuntu 18.04.1 LTS
4.15.0-47-generic
x86_64
# free
              total        used        free      shared  buff/cache   available
Mem:        1009156      324640      109012       52520      575504      473160
Swap:       1048572      357888      690684

Может ли причина ошибки на AWS Ubuntu 16 в том, что что-то не настроено должным образом? Хотя я установил и настроил оба сервера, может быть, я что-то пропустил в AWS Ubuntu 16?

Спасибо!

...