PHPのbuild時にopenSSLが存在しないとエラーが出る時の対処法

表題の通り、PHPをコードからbuildする時にopenSSLが存在しないためconfigureが上手く行かない時の対処法

起きていること

./configure --prefix=$PWD/bin --enable-debug --with-openssl=/usr/bin/openssl --enable-mbstring

--with-opensslのオプションにディレクトリを指定してあげると、以下のエラーが発生する。

configure: error: Cannot find OpenSSL's <evp.h>

対処法

公式やGitHubのissueをチェックすると、「そもそもpkg-configが存在しないのがダメなのでは?」と考える。

https://bugs.php.net/bug.php?id=77392

Cannot find OpenSSL's libraries when I try to install · Issue #138 · mongodb/mongo-php-driver · GitHub

しかし、期待した通りに上手く行かない。

--with-opensslのオプションを変更する

今までは以下のようにオプションを付与していたが、

./configure --prefix=$PWD/bin --enable-debug --with-openssl=/usr/bin/openssl --enable-mbstring

これを下記のように変更する

./configure --prefix=$PWD/bin --enable-debug --with-openssl --enable-mbstring

これで上手くいった

なぜ--with-openssl=/usr/local/opensslだと上手くいかなかったのか?

そもそも、なぜconfigureはincludeファイルを見つけることができなかったのか?

compiling - How to add libraries path to the ./configure command? - Ask Ubuntu

compiling - What is the correct syntax to add CFLAGS and LDFLAGS to "configure"? - Unix & Linux Stack Exchange

ココらへんにヒントがありそう