Last Updated on 2016年6月9日 by かんりにん
phpの環境確認のため、いちいちhtdocs以下にinfo.phpとかを置くのもアレなので
コマンドライン上で手っ取り早く。
参考サイト
お世話になっております!
http://jp2.php.net/manual/ja/function.phpinfo.php
参考にしたコマンドラインオプション
man phpから抜粋。
-r code Run PHP code without using script tags ’<?..?>’ phpコマンドにて、オプション-r をつけ、<?~?>をはずした状態でコードを書くとOKらしい。
書式
- コマンドとオプション
$ php -r 'phpinfo();'
実行結果
ズラズラと。
$ php -r 'phpinfo();' phpinfo() PHP Version => 5.1.6 System => Linux www11088u.sakura.ne.jp 2.6.18-194.26.1.el5 #1 SMP Tue Nov 9 12: 54:20 EST 2010 x86_64 Build Date => Mar 31 2010 02:30:10 Configure Command => './configure' '--build=x86_64-redhat-linux-gnu' '--host=x 86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdi r=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedi r=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=. ./config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-conf ig-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '-- without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freet ype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '-- with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--w ith-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quote s' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '-- enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerb eros' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limi t' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime -magic=/usr/share/file/magic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '-- with-xml' '--with-system-tzdata' '--enable-force-cgi-redirect' '--enable-pcntl' '- -with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbstr-en c-trans' '--enable-mbregex' '--with-ncurses=shared' '--with-gd=shared' '--enable-b cmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--wi th-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=share d,/usr/lib64/mysql/mysql_config' '--enable-dom=shared' '--with-dom-xslt=/usr' '--w ith-dom-exslt=/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--enable-soap =shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter= shared' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC, /usr' '--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config' '--with-pdo-pgsql=sh ared,/usr' '--with-pdo-sqlite=shared,/usr' '--enable-dbase=shared' Server API => Command Line Interface Virtual Directory Support => disabled Configuration File (php.ini) Path => /etc/php.ini Scan this dir for additional .ini files => /etc/php.d additional .ini files parsed => /etc/php.d/Fileinfo.ini, /etc/php.d/bcmath.ini, /etc/php.d/dba.ini, /etc/php.d/dbase.ini, /etc/php.d/dom.ini, /etc/php.d/gd.ini, /etc/php.d/imap.ini, /etc/php.d/ldap.ini, /etc/php.d/mbstring.ini, /etc/php.d/mcrypt.ini, /etc/php.d/memcache.ini, /etc/php.d/mhash.ini, /etc/php.d/mssql.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/ncurses.ini, /etc/php.d/odbc.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_odbc.ini, /etc/php.d/pdo_pgsql.ini, /etc/php.d/pdo_sqlite.ini, /etc/php.d/pgsql.ini, /etc/php.d/readline.ini, /etc/php.d/snmp.ini, /etc/php.d/soap.ini, /etc/php.d/tidy.ini, /etc/php.d/xmlreader.ini, /etc/php.d/xmlrpc.ini, /etc/php.d/xmlwriter.ini, /etc/php.d/xsl.ini PHP API => 20041225 PHP Extension => 20050922 Zend Extension => 220051025 Debug Build => no Thread Safety => disabled Zend Memory Manager => enabled …以下、延々と。
おまけ:出力結果をテキストに落とすときに警告メッセージ
リダイレクトでテキストに落とそうとしたら、timezoneの設定云々で叱られた。
- リダイレクトした時のエラーメッセージ(というよりお叱りメッセージ)
$ php -r 'phpinfo();' > phpinfo.txt PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_s et() function. In case you used any of those methods and you are still getting thi s warning, you most likely misspelled the timezone identifier. We selected 'Asia/T okyo' for 'JST/9.0/no DST' instead in Command line code on line 1
よく見ると、’’"date.timezone"をセッティングしましょう”、とあったので確認したら、
php.iniにdate.timezoneの設定がされていなかった、という大変ダサい話でした…
リダイレクトしたファイルには、上記のお叱りメッセージは出力されていませんでした。標準出力だけでしたか。
date.timezoneの値を指定してOKです。
おまけ2:出力した内容を整形
テキストで落とした内容はwebで見るときと違って当然整形されてないので
せめてエクセルに張り付けるとき楽になるように、sedを使ってちょっとタブを入れたり
整形しておくとよいかも。。
※sed例
sed -d 's/=> /\=\>\t/g'