LoginSignup
4
3

More than 3 years have passed since last update.

macOS Catalinaにphpenvでphp7.4.5をインストール

Last updated at Posted at 2020-04-21

エラーの原因が分からず丸一日費やしてしまったので備忘録残しておきます。

phpenvをインストール

$ git clone https://github.com/CHH/phpenv.git
$ phpenv/bin/phpenv-install.sh

.bash_profileに追加

export PATH="$HOME/.phpenv/bin:$PATH"
eval "$(phpenv init -)"

反映

$ source .bash_profile

php-build

$ git clone https://github.com/CHH/php-build.git $HOME/.phpenv/plugins/php-build

必要なものをインストール

$ brew install zlib bzip2 libiconv tidy-html5 krb5 openssl icu4c libedit libxml2

phpenvでphpをインストール

$ phpenv install 7.4.5
[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.4.5 into /Users/nakamurakohki/.phpenv/versions/7.4.5
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.4.5.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.4.5

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

Here are the last 10 lines from the log:

-----------------------------------------

No package 'krb5-gssapi' found
No package 'krb5' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables KERBEROS_CFLAGS
and KERBEROS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
-----------------------------------------

The full Log is available at '/tmp/php-build.7.4.5.20200422042550.log'.
[Warn]: Aborting build.

インストールできない。。

いまいち原因が分からず調べていると以下のページを見つけた。

7.4.2だけどまあ大体同じでしょってことでこのコマンドで実行。

$ PHP_BUILD_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-bz2=$(brew --prefix bzip2) --with-iconv=$(brew --prefix libiconv) --with-libedit --with-tidy=$(brew --prefix tidy-html5) --with-openssl" PKG_CONFIG_PATH="$(brew --prefix krb5)/lib/pkgconfig:$(brew --prefix openssl)/lib/pkgconfig:$(brew --prefix icu4c)/lib/pkgconfig:$(brew --prefix libedit)/lib/pkgconfig:$(brew --prefix libxml2)/lib/pkgconfig" phpenv install 7.4.5

待つこと20分

[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.4.5 into /Users/nakamurakohki/.phpenv/versions/7.4.5
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.4.5.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.4.5
[Compiling]: /var/tmp/php-build/source/7.4.5
[xdebug]: Installing version 2.9.4
[Downloading]: http://xdebug.org/files/xdebug-2.9.4.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.9.4
[xdebug]: Installing xdebug configuration in /Users/nakamurakohki/.phpenv/versions/7.4.5/etc/conf.d/xdebug.ini
[xdebug]: Cleaning up.
[Info]: Enabling Opcache...
[Info]: Done
[Info]: The Log File is not empty, but the Build did not fail. Maybe just warnings got logged. You can review the log in /tmp/php-build.7.4.5.20200422043526.log or rebuild with '--verbose' option
[Success]: Built 7.4.5 successfully.

できた

確認

$ php -v
PHP 7.4.5 (cli) (built: Apr 18 2020 03:17:54) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies
$ which php
/Users/username/.phpenv/shims/php

ちゃんとphpenvのphpを参照してますね。

mission complete!!

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