LoginSignup
1
1

More than 1 year has passed since last update.

phpenv: PHPビルド時エラーの解消

Posted at

経緯

phpenv(https://github.com/phpenv/phpenv) を利用してPHP 8.1.6をインストールしようとしたところ、以下のようなエラーが表示されPHPのビルドに失敗した。
その後、いくつかのパッケージをインストールし、実行時に環境変数を渡すことでビルドが成功したため、その際のメモ。

-----------------
|  BUILD ERROR  |
-----------------

Here are the last 10 lines from the log:

-----------------------------------------
grep: invalid option -- P
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]
configure: WARNING: unrecognized options: --with-png-dir, --with-icu-dir
configure: error: Please reinstall the BZip2 distribution
-----------------------------------------

環境

  • MacBook Pro (13-inch, M1, 2020)
  • macOS Monterey 12.4
  • homebrew: (/opt/homebrew/opt以下にパッケージがインストールされる設定)

手順

  • homebrew
brew install \
    autoconf \
    bzip2 \
    icu4c \
    krb5 \
    libedit \
    libiconv \
    libjpeg \
    libpng \
    libxml2 \
    libzip \
    oniguruma \
    openssl@1.1 \
    pkg-config \
    tidy-html5 \
    libxslt \
    pcre2
  • ビルド
PHP_RPATHS="$(brew --prefix bzip2)" \
PHP_BUILD_CONFIGURE_OPTS="--with-bz2=$(brew --prefix bzip2) --with-iconv=$(brew --prefix libiconv) --with-tidy=$(brew --prefix tidy-html5) --with-external-pcre=$(brew --prefix pcre2) --with-zip --enable-intl --with-pear" \
PKG_CONFIG_PATH="/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libedit/lib/pkgconfig:/usr/local/opt/libjpeg/lib/pkgconfig:/usr/local/opt/libpng/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/libzip/lib/pkgconfig:/usr/local/opt/oniguruma/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/tidy-html5/lib/pkgconfig" \
phpenv install 8.1.6

参考

以下参考にした記事

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