[php] allow_url_fopenがONになっているのにfile_get_contentsやsimplexml_load_fileがFalseになる
Docker上のalpine linuxで稼働しているH2O+PHP環境にてfile_get_contentsやsimplexml_load_fileがFalseで返ってくる問題に直面した
php.iniのallow_url_fopen はOnになっていることはCLI上とphpinfo()上両方で確認済みなのになぜかFalseになる。
結局問題は解決したが、原因は「phpのOpenSSL moduleがインストールされておらずHTTPSへのサイトへの接続ができなかったため」と判明した。
一度PHPのエラーログをすべて吐く設定にしたところ
Warning: simplexml_load_file() [function.simplexml-load-file]: Unable to find the wrapper “https” – did you forget to enable it when you configured PHP? in
というエラーが発生していた
エラーの内容は「OpenSSLが有効になっていない」とのことで
alpine linuxで下記コマンドを入力しPHPとphp-opensslをUpdateするとfile_get_contentsやsimplexml_load_fileが動いた。
apk add --update --no-cache php7 php7-openssl
確かにphpinfo()でOpenSSLの項目がずっぽり抜けていたが、上記コマンドでphpinfo()でOpenSSLの欄が出現していた。