サンプルコード
LinuxのWhoisコマンドを使ってドメイン情報を取得します
<?php exec('whois -h whois.jp yahoo.co.jp', $arr); foreach ($arr as $key=>$row) { var_dump($row); } ?>
string(79) "[ JPRS database provides information on network administration. Its use is ]" string(79) "[ restricted to network administration purposes. For further information, ]" string(79) "[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ]" string(79) "[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ]" string(0) "" string(40) "Domain Information: [ドメイン情報]" string(48) "a. [ドメイン名] YAHOO.CO.JP" string(70) "e. [そしきめい] やふーかぶしきがいしゃ" string(56) "f. [組織名] ヤフー株式会社" string(55) "g. [Organization] Yahoo Japan Corporation" string(48) "k. [組織種別] 株式会社" string(43) "l. [Organization Type] Corporation" string(46) "m. [登録担当者] HT46858JP" string(48) "n. [技術連絡担当者] KM56800JP" string(54) "p. [ネームサーバ] ns01.yahoo.co.jp" string(54) "p. [ネームサーバ] ns02.yahoo.co.jp" string(54) "p. [ネームサーバ] ns11.yahoo.co.jp" string(54) "p. [ネームサーバ] ns12.yahoo.co.jp" string(14) "s. [署名鍵]" string(56) "[状態] Connected (2020/09/30)" string(47) "[登録年月日] 2019/09/27" string(47) "[接続年月日] 2019/09/27" string(61) "[最終更新] 2019/12/05 15:07:15 (JST)" string(0) ""
whoisコマンドが入ってない場合はwhoisをインストール
CentOS 8 の場合
※デフォルトではwhoisが入っていないので、EPELリポジトリを利用します dnf -y install epel-release dnf -y install whois
CentOS 7 の場合
※デフォルトではwhoisが入っていないので、EPELリポジトリを利用します yum -y install epel-release yum -y install jwhois