mysqlndのインストール中 PHP拡張、およびconfigure スクリプトが実行されましたが、エラーが発生しました– OpenSSL
以下は完全なエラーメッセージです:
[root@terra-node-01 mysqlnd]# ./configure [...] checking for X509_free in -lcrypto... yes checking for pkg-config... /bin/pkg-config configure: error: Cannot find OpenSSL's <evp.h>
解決策:OpenSSLが見つかりません
ステップ1:evp.hを検索
[root@terra-node-01 mysqlnd]# locate evp.h /opt/at12.0/include/openssl/evp.h /opt/at12.0/share/doc/openssl/html/man7/evp.html /usr/include/openssl/evp.h
ステップ2:PHP_OPENSSL_DIR環境変数を設定します
configureスクリプトは、それを探す場所を見つけるのに役立つ必要があります。 configureスクリプトがどのようにそのファイルを検索しようとしているのか見てみましょう。お気に入りのエディターを使用して構成ファイルを開き、以下に示すブロックに移動します。
[root@terra-node-01 mysqlnd]# vim configure
[...]
for i in $PHP_OPENSSL_DIR; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_INCDIR=$i/include
fi
if test -r $i/$PHP_LIBDIR/libssl.a -o -r $i/$PHP_LIBDIR/libssl.$SHLIB_SUFFIX_NAME; then
OPENSSL_LIBDIR=$i/$PHP_LIBDIR
fi
test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
done
if test -z "$OPENSSL_INCDIR"; then
as_fn_error $? "Cannot find OpenSSL's <evp.h>" "$LINENO" 5
fi
if test -z "$OPENSSL_LIBDIR"; then
as_fn_error $? "Cannot find OpenSSL's libraries" "$LINENO" 5
fi
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS=-I$OPENSSL_INCDIR
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenSSL version" >&5
$as_echo_n "checking for OpenSSL version... " >&6; }
[...]
上記のコードを観察すると、configureはPHP_OPENSSL_DIRなどの変数を使用します evp.hを検索するには 。 PHP_OPENSSL_DIRをエコーする場合 変数の場合、/usr,が含まれていないことがわかります。 ここでevp.h が存在し、それを見る必要があります。したがって、解決策は、この変数を環境変数として定義し、エクスポートして、configureを再度実行することです。
[root@terra-node-01 mysqlnd]# PHP_OPENSSL_DIR="/usr" [root@terra-node-01 mysqlnd]# export PHP_OPENSSL_DIR [root@terra-node-01 mysqlnd]# ./configure [...] checking for X509_free in -lcrypto... yes checking for pkg-config... /bin/pkg-config configure: error: Cannot find OpenSSL's libraries
おー!これ以上evp.h エラーが発生しましたが、別のエラーが発生しました:OpenSSLのライブラリが見つかりません。 上記と同じ手法を使用して、OpenSSLライブラリのパスを見つけましょう。
ステップ3:OpenSSLライブラリパスを検索する
[root@terra-node-01 mysqlnd]# locate libssl.so locate libssl.so /opt/at12.0/lib64/libssl.so /opt/at12.0/lib64/libssl.so.1.1 /opt/at12.0/lib64/power8/libssl.so /opt/at12.0/lib64/power8/libssl.so.1.1 /opt/at12.0/lib64/power9/libssl.so /opt/at12.0/lib64/power9/libssl.so.1.1 /usr/lib64/.libssl.so.1.0.2k.hmac /usr/lib64/.libssl.so.10.hmac /usr/lib64/libssl.so /usr/lib64/libssl.so.1.0.2k /usr/lib64/libssl.so.10
ステップ3:OpenSSLライブラリパスをPHP_OPENSSL_DIRに追加します
OpenSSLlibsパス/usr/lib64を追加します PHP_OPENSSL_DIRへ 環境変数。
[root@terra-node-01 mysqlnd]# PHP_OPENSSL_DIR="/usr /usr/lib64" [root@terra-node-01 mysqlnd]# export PHP_OPENSSL_DIR
残念ながら、それだけでは問題は解決しませんでした。構成コードを分析した後、PHP_LIBDIRという別の環境変数を設定する必要があることがわかりました。 。ただし、この変数は環境から読み取られるのではなく、以下の構成コードのスニペットからわかるように引数によって読み取られます。
[root@terra-node-01 mysqlnd]# vim configure
[...]
# Check whether --with-libdir was given.
if test "${with_libdir+set}" = set; then :
withval=$with_libdir; PHP_LIBDIR=$withval
そこで、新しい引数--with-libdir=""を追加しました configureの実行中
[root@terra-node-01 mysqlnd]# ./configure --with-libdir="" [...] creating libtool appending configuration tag "CXX" to libtool configure: creating ./config.status config.status: creating config.h config.status: config.h is unchanged
これで構成スクリプトが正常に完了しました。makeに進んでください。 およびmake install 。