複数のPHPバージョンをインストールして切替できるphpenvの記事を以前書きましたが、
その後、PHPもいくつかのアップデートがリリースされています。
最新のPHPバージョンをインストールできるようにするには、
phpenv/php-build パッケージの定義ファイルを更新していく必要があります。
前提条件
- phpenvインストール済
- Ubuntu上で作業しています。
定義ファイル更新
bashのターミナル上で次のコマンドを実行します。
phpenv update
![](https://macocci7.net/blog/wp-content/uploads/2024/04/phpenv_update_01.png)
phpenv/php-build パッケージの git pull が行われていることが判ります。
remote: Enumerating objects: 46, done.
remote: Counting objects: 100% (46/46), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 46 (delta 26), reused 20 (delta 10), pack-reused 0
Unpacking objects: 100% (46/46), 20.62 KiB | 459.00 KiB/s, done.
From https://github.com/php-build/php-build
ee951b9..e8b8ca3 master -> origin/master
Updating ee951b9..e8b8ca3
Fast-forward
.github/workflows/ci.yml | 10 +++++-----
.travis.yml | 6 +++---
CHANGELOG.md | 6 +++---
run-tests.sh | 2 +-
share/php-build/definitions/8.1.27 | 10 ++++++++++
share/php-build/definitions/8.1.28 | 10 ++++++++++
share/php-build/definitions/8.2.14 | 10 ++++++++++
share/php-build/definitions/8.2.15 | 10 ++++++++++
share/php-build/definitions/8.2.16 | 10 ++++++++++
share/php-build/definitions/8.2.17 | 10 ++++++++++
share/php-build/definitions/8.2.18 | 10 ++++++++++
share/php-build/definitions/8.3.1 | 10 ++++++++++
share/php-build/definitions/8.3.2 | 10 ++++++++++
share/php-build/definitions/8.3.3 | 10 ++++++++++
share/php-build/definitions/8.3.4 | 10 ++++++++++
share/php-build/definitions/8.3.5 | 10 ++++++++++
share/php-build/definitions/8.3.6 | 10 ++++++++++
17 files changed, 142 insertions(+), 12 deletions(-)
create mode 100644 share/php-build/definitions/8.1.27
create mode 100644 share/php-build/definitions/8.1.28
create mode 100644 share/php-build/definitions/8.2.14
create mode 100644 share/php-build/definitions/8.2.15
create mode 100644 share/php-build/definitions/8.2.16
create mode 100644 share/php-build/definitions/8.2.17
create mode 100644 share/php-build/definitions/8.2.18
create mode 100644 share/php-build/definitions/8.3.1
create mode 100644 share/php-build/definitions/8.3.2
create mode 100644 share/php-build/definitions/8.3.3
create mode 100644 share/php-build/definitions/8.3.4
create mode 100644 share/php-build/definitions/8.3.5
create mode 100644 share/php-build/definitions/8.3.6
この記事の執筆時点での最新バージョンは
8.3.6 / 8.2.18 / 8.1.28 です。
![](https://macocci7.net/blog/wp-content/uploads/2024/04/phpenv_update_02-1024x614.png)
最新版の定義ファイルが反映されているようです。
最新版のPHPインストール
折角定義ファイルを更新したので、
最新版のPHPバージョンをインストールしていきます。
まずは8.1から。
PHP_BUILD_INSTALL_EXTENSION="imagick=@" phpenv install 8.1.28
![](https://macocci7.net/blog/wp-content/uploads/2024/04/phpenv_update_03.png)
Warningがいくつか出ていますが、
大きな問題なくインストール完了です。
[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.28 into /home/macocci7/.phpenv/versions/8.1.28
[Downloading]: https://www.php.net/distributions/php-8.1.28.tar.bz2
[Preparing]: /tmp/php-build/source/8.1.28
[Compiling]: /tmp/php-build/source/8.1.28
[xdebug]: Installing version 3.3.1
[Skipping]: Already downloaded http://xdebug.org/files/xdebug-3.3.1.tgz
[xdebug]: Compiling xdebug in /tmp/php-build/source/xdebug-3.3.1
[xdebug]: Installing xdebug configuration in /home/macocci7/.phpenv/versions/8.1.28/etc/conf.d/xdebug.ini
[xdebug]: Cleaning up.
Makefile:244: warning: overriding recipe for target 'test'
Makefile:136: warning: ignoring old recipe for target 'test'
[Info]: Enabling Opcache...
[Info]: Done
[imagick]: Installing from source
[imagick]: Updating imagick from Git Master
Removing Makefile
Removing Makefile.fragments
Removing Makefile.objects
Removing autom4te.cache/
Removing build/
Removing config.h
Removing config.h.in
Removing config.log
Removing config.nice
Removing config.status
Removing configure
Removing configure.ac
Removing include/
Removing libtool
Removing modules/
Removing run-tests.php
HEAD is now at 28f2704 Fix variable name on error.
[imagick]: Checkout specified revision: origin/master
HEAD is now at 28f2704 Fix variable name on error.
[imagick]: Compiling imagick in /tmp/php-build/source/imagick-master
[imagick]: Installing imagick configuration in /home/macocci7/.phpenv/versions/8.1.28/etc/conf.d/imagick.ini
[imagick]: Cleaning up.
[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.28.20240420091218.log or rebuild with '--verbose' option
[Success]: Built 8.1.28 successfully.
8.1 => 8.1.28
phpenv の shim をリビルドします。
phpenv rehash
phpenv で PHP8.1.28 に切替します。
phpenv global 8.1.28
PHPのバージョンを確認します。
php -v
![](https://macocci7.net/blog/wp-content/uploads/2024/04/phpenv_update_04.png)
PHP8.1.28に切り替わっていますね。
PHP8.2.18 / PHP8.3.6 についても同じ手順でインストールすれば最新版にできます。
PHP_BUILD_INSTALL_EXTENSION="imagick=@" phpenv install 8.2.18
PHP_BUILD_INSTALL_EXTENSION="imagick=@" phpenv install 8.3.6
以上です。
コメント