已启动nginx个php-cgi
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2355/nginx  
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      2212/php-cgi phpinfo.php脚本  
<?php 
phpinfo();
?>
nginx配置
location / {
            root   html;
            index  index.php index.html index.htm;
        }location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /html$fastcgi_script_name;
            include        fastcgi_params;
        }打开localhost/ 能正常
打开localhost/phpinfo.php的时候  出来的是提示下载整个php文件  而不是php执行的结果  刚刚入手php 高高手解答  看了网上好多资料 还是没搞定

解决方案 »

  1.   

    fastcgi_param  SCRIPT_FILENAME  /html$fastcgi_script_name;
    /html是绝对路径,估计是路径错了
    fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      

  2.   

    显然还是没有能够正确的解析PHP脚本,环境有问题.我不知道你的是什么系统 如果是ubuntu  建议你使用系统自带的 nginx 和 php 不要折腾了会简单很多.
      

  3.   

    fastcgi_param  SCRIPT_FILENAME  /html$fastcgi_script_name;
    /html 写绝对路径试试
      

  4.   

    location ~ \.php$ {
                root           html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
                include        fastcgi_params;
            }还是一样的效果 我怀疑不是路径有问题 是nginx和php没关联起来