Nginx报错:no input file specified 解决方案

上周 对nginx一些参数进行调优 过了6小时候 却出了问题 页面没一直报错:no input file specified(也就是nginx找不到php页面)

重启一下php,就好了,但过了1小时左右,问题又复现,且频率极不稳定,刷新5次 有4次会报错

 网上找了些资料 尝试修改参数然后进行监控,目前稳定运行4天

 

初步判断是nginx的参数  $document_root 出问题

  location ~ ^(.+\.php)(.*)$
    {
      fastcgi_split_path_info ^(.+\.php)(.*)$;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      #fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      fastcgi_param  SCRIPT_FILENAME    /data/htdocs/html$fastcgi_script_name; #改成绝对路径
      fastcgi_param  PATH_INFO          $fastcgi_path_info;
      include fastcgi.conf;
    }

 

将 $document_root 改成绝对路径就好了

$document_root原本就是路径的参数,出这样的问题,且是不稳定的概率事件,的确让人费解

 

除了这个参数外,也改过其它的也全部列举出来,对以后碰见类似问题也有个参考

 修改 nginx

  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 64k;
  #fastcgi_buffers 4 64k;
  fastcgi_busy_buffers_size 128k;
  fastcgi_temp_file_write_size 128k;
  fastcgi_intercept_errors on; #开启 让fastcgi将不存在的PHP程序文件交回给nginx即可

  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 16k;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_types       text/plain application/x-javascript text/css application/xml;
  gzip_vary on;

 

修改 php

; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues.  The alternate is to use the
; cgi.force_redirect configuration below
; http://php.net/doc-root
; doc_root =  ;注释掉 一旦写入php地址也这里的为主

 

 

posted @ 2012-05-02 17:27  toroy  阅读(326)  评论(0)    收藏  举报