2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

EC2にlaravelをデプロイしようとしたらcomposerで詰まりました(初心者目線)

Last updated at Posted at 2020-03-05

#前提バージョン
laravel 5.8
php 7.2
composer 1.9.3
#エラー箇所
composer installで詰まりました。
足りていないphp関連をインストールしろとアナウンスが出ています。

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework v5.8.35 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.8.35 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - Installation request for laravel/framework v5.8.35 -> satisfiable by laravel/framework[v5.8.35].

#解決方法
$yum install php72-php-mysqlnd php72-php-mbstring php72-php-gd
これでもう一度composer install

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - tijsverkoyen/css-to-inline-styles 2.2.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - tijsverkoyen/css-to-inline-styles 2.2.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - Installation request for tijsverkoyen/css-to-inline-styles 2.2.2 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.2].

エラー内容が代わりました。

$sudo yum install php72-php-dom
これで解決

###インストールされたか確認

$ php --iniで実際にインストールされかた確認してみるとたしかにdomが入っていますね。

$ php --ini
Configuration File (php.ini) Path: /etc/opt/remi/php72
Loaded Configuration File:         /etc/opt/remi/php72/php.ini
Scan for additional .ini files in: /etc/opt/remi/php72/php.d
Additional .ini files parsed:      /etc/opt/remi/php72/php.d/20-bz2.ini,
/etc/opt/remi/php72/php.d/20-calendar.ini,
/etc/opt/remi/php72/php.d/20-ctype.ini,
/etc/opt/remi/php72/php.d/20-curl.ini,
/etc/opt/remi/php72/php.d/20-dom.ini,
/etc/opt/remi/php72/php.d/20-exif.ini,
/etc/opt/remi/php72/php.d/20-fileinfo.ini,
/etc/opt/remi/php72/php.d/20-ftp.ini,
/etc/opt/remi/php72/php.d/20-gd.ini,
/etc/opt/remi/php72/php.d/20-gettext.ini,
/etc/opt/remi/php72/php.d/20-iconv.ini,
/etc/opt/remi/php72/php.d/20-json.ini,
/etc/opt/remi/php72/php.d/20-mbstring.ini,
/etc/opt/remi/php72/php.d/20-mysqlnd.ini,
/etc/opt/remi/php72/php.d/20-pdo.ini,
/etc/opt/remi/php72/php.d/20-phar.ini,
/etc/opt/remi/php72/php.d/20-simplexml.ini,
/etc/opt/remi/php72/php.d/20-sockets.ini,
/etc/opt/remi/php72/php.d/20-sqlite3.ini,
/etc/opt/remi/php72/php.d/20-tokenizer.ini,
/etc/opt/remi/php72/php.d/20-xml.ini,
/etc/opt/remi/php72/php.d/20-xmlwriter.ini,
/etc/opt/remi/php72/php.d/20-xsl.ini,
/etc/opt/remi/php72/php.d/30-mysqli.ini,
/etc/opt/remi/php72/php.d/30-pdo_mysql.ini,
/etc/opt/remi/php72/php.d/30-pdo_sqlite.ini,
/etc/opt/remi/php72/php.d/30-wddx.ini,
/etc/opt/remi/php72/php.d/30-xmlreader.ini

ここまで来たらもう一度composer install実行します。
するとcomposer updateしてとアナウンスされました。

$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. It is recommended that you run `composer update` or `composer update <package name>`.
Nothing to install or update
Generating optimized autoload files
Warning: Ambiguous class resolution, "App\Http\Requests\ProfileRequest" was found in both "/var/www/html/tree2/tree2/myblog/app/Http/Controllers/IdRequest.php" and "/var/www/html/tree2/tree2/myblog/app/Http/Requests/ProfileRequest.php", the first will be used.
Warning: Ambiguous class resolution, "App\User" was found in both "/var/www/html/tree2/tree2/myblog/app/Http/Controllers/User.php" and "/var/www/html/tree2/tree2/myblog/app/User.php", the first will be 
~(省略)~



composer update実行


[ec2-user@ip-172-31-36-97 myblog]$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 39 updates, 0 removals
  - Updating symfony/polyfill-ctype (v1.13.1 => v1.14.0): The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

PHP Warning:  proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 952

Warning: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 952

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

~(省略)~

なにやらエラーが出ています。
メモリが足りないみたいなので容量を大きくします。

$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
$ sudo /sbin/mkswap /var/swap.1
$ sudo /sbin/swapon /var/swap.1

これでcomposer updatecomposer installが行けるはず!

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?