1
0

More than 1 year has passed since last update.

初心者がWSL2 + Docker Desktop + PhpStorm でPHP開発環境構築で詰まった話

Posted at

実行手順

こちらのブログを参考に構築しました。

起きた問題

docker-compose build が失敗する。

=> ERROR [php-fpm 3/8] RUN pecl install -f xdebug && docker-php-ext-enable xdebug && apk del --purge autoconf g++ make 5.6s

上記のエラーメッセージが表示ながらも、docker-compose build自体は止まらず。
別Ubuntu Window で強制終了た。

強制終了のコマンド:

ps aux | grep docker-compose

でプロセスコードを確認

kill -p プロセスコード

で強制終了

問題特定まで

docker-compose build --no-cache --progress=plain

でエラーメッセージの詳細を特定

#6 5.953 configure: error: rtnetlink.h is required, install the linux-headers package: apk add --update linux-headers
#6 5.967 ERROR: `/tmp/pear/temp/xdebug/configure --with-php-config=/usr/local/bin/php-config' failed
#6 ERROR: process "/bin/sh -c pecl install -f xdebug     && docker-php-ext-enable xdebug     && apk del --purge autoconf g++ make" did not complete successfully: exit code: 1

以下のエラーメッセージで
#6 5.953 configure: error: rtnetlink.h is required, install the linux-headers package: apk add --update linux-headers

xdebugのインストールにはrtnetlink.hというヘッダーファイルが必要であることは判明。

よってDockerfileを修正。

RUN apk update \
    && apk upgrade \
    && apk add --no-cache \
        bash \
        libzip-dev \
        libpng-dev \
        linux-headers \  # <-- この行を追加
    && docker-php-ext-install \
        pdo_mysql \
        bcmath \
        gd \
        opcache \
        zip \
    && apk --update --no-cache add autoconf g++ make

参考元ファイルはこちら:

これで解決。

結論

なぜ自分の環境ではこれが必要が不明だが、いったんこれで解決。

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