Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

CGI版PHPで"Unexpected character in input ... state=1"が出る

もう、本当に備忘録。環境はApache2.0.63+PHP4.3.9(CGI版)。
PHPのconfigureオプションは、

--prefix=/usr/local/lib/php-4.3.9 --enable-zend-multibyte --disable-ipv6 --enable-discard-path --enable-mbstring --enable-mbregex --with-openssl

で、php.ini-recommendedをphp.iniとしてコピー。
httpd.confは、

DocumentRoot /path/to/docroot
<Directory "/path/to/docroot">
    Options ExecCGI
</Directory>

ScriptAlias /cgi-bin/ /usr/local/lib/php-4.3.9/bin/
Action application/x-httpd-php /cgi-bin/php
AddType application/x-httpd-php .php

な感じ。ここで、以下のようなphpinfo.php

<?php phpinfo();

を実行すると、

Warning: Unexpected character in input: '' (ASCII=22) state=1 in /usr/local/lib/php-4.3.9/bin/php on line 1563

というエラーが。。。
これの回避方法は、php.iniにある

; cgi.fix_pathinfo=1

をアンコメントする。

参考:http://www.webhostingtalk.com/showthread.php?t=683737