6
3

More than 3 years have passed since last update.

composer installで発生したエラーの解決法

Last updated at Posted at 2020-11-29

AWSを学習中の者です。
以下の記事を参考にAWSを触ってみたところエラーが発生しましたので自分用メモとして残します。
AWSでウェブアプリケーション環境構築:②RDSでDBを作成し、Laravelサンプルアプリを動かす最小構成を構築

【エラー発生箇所1】

PHP拡張モジュールインストール時にトランザクションエラーが発生

【エラー文】

Transaction check error:
file /usr/lib64/php-zts/modules/zip.so from install of php-pecl-zip-1.15.2-3.amzn2.0.1.x86_64 conflicts with file from package php-common-7.2.29-1.amzn2.x86_64

file /usr/lib64/php/modules/zip.so from install of php-pecl-zip-1.15.2-3.amzn2.0.1.x86_64 conflicts with file from package php-common-7.2.29-1.amzn2.x86_64

———————————————
競合が発生しインストールが失敗したようです。
このままでも進められないかと試みたのですが、以下のところでエラーが発生してしまいました。

【エラー発生箇所2】

php7.2をインストール後、composer installしたところでエラーが発生

【エラー文】

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

To enable extensions, verify that they are enabled in your .ini files:

—————————————
エラー発生箇所1が原因でext-mbstringとext-domがインストールされなかった為インストール失敗したようです。

【試したこと】

ext-mbstringとext-domを別途インストールしました。
具体的な手順を以下に示します。

ext-mbstringのインストール手順

webサーバにSSHログイン後、ターミナル上で以下のように入力します。

cd /var/www/html/laravel-sample
php -v 
yum list | grep "\-mbstring"

実行結果
実行結果.png

php-mbstring.x86_64がインストール可能のようなのでインストールします。

sudo  yum install php-mbstring.x86_64

インストール完了.png

ext-mbstringがインストールできました。

ext-domのインストール手順

ext-domはphp-xmlをインストールすることでext-domを導入できるそうです。
以下のコマンドでphp7.2(自分の環境)でインストール可能なphp-xmlを探します。

 yum list php* | grep amzn2extra-php7.2

実行結果(一部)
一覧一部.png

php-xml.x86_64がインストール可能のようなのでインストールします。

 sudo yum install php-xml.x86_64

実行結果
インストール完了2.png

php-xmlがインストールできました。

もう一度composer installを実行

composer installが失敗した原因となるエラーを解決できたのでもう一度composer installを実行します。

cd /var/www/html/laravel-sample
composer install

実行結果
インストール完了3.png

composer installが実行できました。

参考にしたサイト一覧

Amazon Linuxでphpでmbstringを使う

composerでlaravelを導入しようとして発生したエラー「ext-mbstring」「ext-dom」

6
3
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
6
3