LoginSignup
1
1

More than 1 year has passed since last update.

macOS に phpenv で PHP 8.1 をインストールする

Posted at

PHP 8.1.0 が2021年11月25日にリリースされて、 phpenv + php-build では2020年11月29日に PHP 8.1.0 が追加された(ちなみに、 PHP 8.1.0 を追加する PR は私が送った)ので、早速 macOS にインストールしてみた。

といっても PHP 8.0 のときと変わらず、下記のコマンドでインストールできた。

$ PHP_BUILD_CONFIGURE_OPTS="--with-bz2=/usr/local/opt/bzip2 --with-iconv=/usr/local/opt/libiconv" phpenv install 8.1.0

下記のような感じで、問題なくインストールできていることを確認した。

$ phpenv versions
  5.6.40
  7.0.33
  7.1
  7.1.33
  7.2
  7.2.34
  7.3.32
* 7.4 (set by /Users/tagawa/.anyenv/envs/phpenv/version)
  7.4.26
  8.0
  8.0.13
  8.1
  8.1.0
$ phpenv shell 8.1.0
8.1.0
$ php -v
PHP 8.1.0 (cli) (built: Nov 29 2021 11:23:44) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies
    with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans

以上です。どなたかのご参考になれば幸いです。


以下、インストールした環境やエラーメッセージなどのメモ。

環境

  • macOS: 12.0.1
  • phpenv: v0.9.0-rc.1
  • php-build: v0.11.0dev

はじめに実行したコマンド

phpenv を最新の状態にして、

$ phpenv update

PHP 8.1.0 をインストールしようとしたところ、 PHP 8.0 のときと同じように bzpi2iconv でエラーが発生した。

$ phpenv install 8.1.0

エラーメッセージ

bzip2

configure: WARNING: unrecognized options: --with-png-dir, --with-libxml-dir, --with-icu-dir
configure: error: Please reinstall the BZip2 distribution

iconv

configure: WARNING: unrecognized options: --with-png-dir, --with-libxml-dir, --with-icu-dir
configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

解決方法

PHP 8.0 のときと同じように、 brewbzip2iconv をインストールして、冒頭のコマンドのように phpenv でインストールする際にパスを渡す。

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