Featured image of post macOS Mojaveでphpenv installを使ってphpが入らない問題について

macOS Mojaveでphpenv installを使ってphpが入らない問題について

Twitter ツイート Hatena Bookmark ブックマーク

mojaveな環境でphpの実行環境を用意しようと思いphpenv installしたらエラーがでました・・・。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
❯ env PHP_BUILD_CONFIGURE_OPTS=--with-openssl=(brew --prefix openssl) phpenv install 7.2.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.2.9 into /Users/polidog/.anyenv/envs/phpenv/versions/7.2.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.2.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.2.9

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

Here are the last 10 lines from the log:

-----------------------------------------
configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 2.3, min: 204, excluded: ).
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
configure: error: Cannot find libz
-----------------------------------------

どうやらlibzがないのでなんとかしようと思い、ググると@DQNEO大先生のQiitaの記事が! macOS Sierraでconfigure: error: Cannot find libzの対処法

ということでxcode-select --installを実行してみる。

1
2
❯ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

このようにエラーになってしまう。

libzがないと言われる原因について

どうやらMojaveの場合はxcode-selectの最新でmacOS SDK headerがないのが行けないみたいです。

対処法

参考の記事を見てもらえればわかりますが、以下のようにコマンドを実行します。

1
> sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

そのphpenvでphpのインストールをすれば大丈夫です。

1
❯ env PHP_BUILD_CONFIGURE_OPTS=--with-openssl=(brew --prefix openssl) phpenv install 7.2.9

参考

Install failed, “zlib not available” on macOS Mojave #1219

おまけ

phpインストールする際はいろいろと依存関係おおいので、以下のライブラリを入れておくのが良さそう

1
2
3
4
5
> brew install bison
> brew install openssl
> brew install libjpeg
> brew install libpng
> brew install icu4c
comments powered by Disqus
Built with Hugo
テーマ StackJimmy によって設計されています。