AlmaLinux9.2にoniguruma6.9.8をソースインストール

覚書です。
ところどころ省いています。
実践環境で使う場合はご注意ください。

目的

PHP8.2.10をAlmaLinux9.2にインストールしようとしたところ configure で次のエラーが発生しました。

checking for oniguruma... no
configure: error: Package requirements (oniguruma) were not met:

Package 'oniguruma', required by 'virtual:world', not 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 ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

ということでonigurumaをインストールすることにします。

ちなみにテストサーバ用途の複数バージョン同居環境の場合、下手にdnfするよりソースからバージョン指定でインストールしておいたほうが将来的にメリットがあります。

特徴

  • ソースコードからのインストール
  • 複数バージョンの共存

特定バージョンでの開発や動作確認など開発環境での用途を目的としています。

環境

実施日2023-09-08
サーバさくらのVPS 2G
OSAlmaLinux9.2
cat /etc/redhat-release
AlmaLinux release 9.2 (Turquoise Kodkod)

事前準備

ダウンロードURLの確認

Githubから入手します。

https://github.com/kkos/oniguruma/tags

2023-09-08時点では「v6.9.8」が最新のようですのでこちらをインストールしていきます。

https://github.com/kkos/oniguruma/releases/tag/v6.9.8

こちらのページの一番下「Source code (tar.gz)」がお目当てです。

URLを控えておきます。

https://github.com/kkos/oniguruma/archive/v6.9.8.tar.gz

インストール

ls -la /usr/local/src
ls -la /usr/local/lib

mkdir /usr/local/src/oniguruma-6.9.8

cd /usr/local/src/oniguruma-6.9.8

wget https://github.com/kkos/oniguruma/archive/v6.9.8.tar.gz

tar xvzf v6.9.8.tar.gz

cd oniguruma-6.9.8

autoreconf -vfi

./configure --prefix=/usr/local/lib/oniguruma-6.9.8

make

make install

PHPのconfigureの前に

PHPのconfigureエラーで次のように出ていると思いますが、ここに書かれているとおり PKG_CONFIG_PATH の設定が必要です。

下記を実行してから、PHPのconfigureを再開します。

export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/oniguruma-6.9.8/lib/pkgconfig"