CGI版のPHPで「No input file specified.」のエラーを解決する方法
nginxでspawn-cgi経由でphp-cgiを動作させているときに
No input file specified.
というようなエラーが出る場合があります。
これはファイルをPHPが探せないという場合に起こるエラーです。
この場合は一度、nginxの設定を見直すのが近道です。
例を見てみましょう。
悪い例(パスは参考例です)
# vi /etc/nginx/nginx.conf location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:12345; # port where FastCGI processes were spawned fastcgi_index index.php; }
PHPスクリプトがどこにあるか、定義されていないので、「No input file specified.」という
CGI経由のエラーが出ます。
いい例
明示的にどこにPHPファイルがあるか登録しましょう。
# vi /etc/nginx/nginx.conf location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:12345; # port where FastCGI processes were spawned fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /path/php/application$fastcgi_script_name; }
これでPHPが無事に実行できると思います。