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

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

JqueryのjQuery-Tags-Inputのコードリーディング

jQuery-Tags-Input/jquery.tagsinput.js at master · xoxco/jQuery-Tags-Input

xoxco.com/projects/code/tagsinput/example.html

使い方

$("#tag").tagInput()

上の様に使える。

コードの中身

疑似的なDOMを作っており、そいつらが描画を変更したり、fake_inputをしたりしている。

var data = jQuery.extend({
                pid:id,
                real_input: '#'+id,
                holder: '#'+id+'_tagsinput',
                input_wrapper: '#'+id+'_addTag',
                fake_input: '#'+id+'_tag'
            },settings);

pidは元々のinputタグ、real_inputはpidと同じ。 holderはwrapper的な奴。 fake_inputはholderの中にある仮のinputタグ