LoginSignup
3
3

More than 1 year has passed since last update.

Ubuntu22.04でphpenv使おうと思ったらopensslのバージョン違いでbuildできない件

Last updated at Posted at 2022-09-13

macの対策はたくさん記事が引っかかるけどubuntuの情報はあまり無いので同様の現象で詰まった方のために残しておきます。
掲題ですが、phpenvとphp-buildをインストールしたubuntu22.04で、php7.4.30や8.0.23をインストールしようとした所、下記のエラーが出ました。下のログは8.0.23をインストールしようとした場合のログですが、7.4.30でも同様のエラーが出ていた筈です。私の環境では7.4.30でも同様の対処でbuild通る様になりました。

-----------------------------------------
/tmp/php-build/source/8.0.23/ext/openssl/xp_ssl.c:1240:9: warning: ‘DH_free’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
 1240 |         DH_free(dh);
      |         ^~~~~~~
In file included from /usr/include/openssl/dsa.h:51,
                 from /usr/include/openssl/x509.h:37,
                 from /usr/include/openssl/ssl.h:31,
                 from /tmp/php-build/source/8.0.23/ext/openssl/xp_ssl.c:31:
/usr/include/openssl/dh.h:200:28: note: declared here
  200 | OSSL_DEPRECATEDIN_3_0 void DH_free(DH *dh);
      |                            ^~~~~~~
-----------------------------------------

どうもOpenSSLのバージョン違いでbuildコケてる様だ、ということで、opensslの1系をインストールしなければならないということまでは分かったのですが、1.1をソースからbuildしてphpenv isntall 8.0.23 --with-openssl=dirみたいなオプションを付けても同様のエラーが出続けて、なんでやねんってなってハマりました。

そこで色々見てみた所、こんなissueが出てました。やっぱ皆困ってるんですね・・・

で、このissueを読むまで知らなかったのですが

  • php-buildにはopenssl 1.0をインストールすることができるbuild-openssl-1.0.shが付属している
  • --with-opensslは機能しない

ということが分かりました。そこで該当のshellを走らせてopenssl1.0をインストールした後、オプションを変更して

PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/openssl@1.0/lib/pkgconfig" phpenv install 8.0.23

で通る様になりました。めでたし。

まあ実は--with-opensslが機能しないのはphp-buildのmanページに書いてあったんですけどね。ちゃんとman読めってことですかねすみません。

with_openssl
Adds --with-openssl to the list of configure options. Legacy command, which is left in for backwards compatibility with definitions written before --with-openssl was moved to the default configure options.
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3