もがき系プログラマの日常

もがき系エンジニアの勉強したこと、日常のこと、気になっている技術、備忘録などを紹介するブログです。

phpenvでphp8.1をインストール

はじめまして

php8.1の案件が来るみたいでローカルに php8.1をインストールしてみました。

例のごとく phpenv です。

本題

とりあえず普通に実行してみます。

$ phpenv install 8.1.6
...
...
...
curl: (56) LibreSSL SSL_read: Connection reset by peer, errno 54

あんまり見ないエラーがでました。

調べてみるとキャッシュ不足とのことでした。

reject.tokyo

今回は参考サイトの対策1で対応してみました。

$ git config http.postBuffer 512M

これで再度実行します。

$ phpenv install 8.1.6
...
...
...
configure: error: Please reinstall the BZip2 distribution

見覚えあるエラーです。

php8.0入れたときにもおんなじようなエラーが出てました。

過去の自分のサイトで使ったインストールコマンドを持ってきて実行してみます。

kojirooooocks.hatenablog.com

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


[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 8.1.6 into /path/to/.anyenv/envs/phpenv/versions/8.1.6
[Skipping]: Already downloaded and extracted https://www.php.net/distributions/php-8.1.6.tar.bz2
[Preparing]: /var/tmp/php-build/source/8.1.6
[Compiling]: /var/tmp/php-build/source/8.1.6
[xdebug]: Installing version 3.1.4
[Downloading]: http://xdebug.org/files/xdebug-3.1.4.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-3.1.4
[xdebug]: Installing xdebug configuration in /path/to/.anyenv/envs/phpenv/versions/8.1.6/etc/conf.d/xdebug.ini
[xdebug]: Cleaning up.
Makefile:240: warning: overriding commands for target `test'
Makefile:133: warning: ignoring old commands for target `test'
[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.8.1.6.20220610234330.log or rebuild with '--verbose' option
[Success]: Built 8.1.6 successfully.
phpenv: cannot rehash: /path/to/.anyenv/envs/phpenv/shims/.phpenv-shim exists
$ phpenv versions
* 7.4.25 (set by /path/to/.anyenv/envs/phpenv/version)
  8.0.12
  8.1.6


$ phpenv global 8.1.6
8.1.6


$ php -v
PHP 8.1.6 (cli) (built: Jun 10 2022 23:47:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
    with Xdebug v3.1.4, Copyright (c) 2002-2022, by Derick Rethans

問題なく入りました!

終わりに

かんたんでしたが、インストールログでした。

php8.1のenum試してみたいから、試したらまた書くかも。

現場からは以上です。