开发者社区> 问答> 正文

ubuntu nginx+php 虚拟主机出现 no input file specified,报错

环境是ubuntu nginx php mysql

如果是正常访问PHP输出是正常的 http://localhost/test/index.php 正常输出

如果是我配置了虚拟主机PHP文件就无法正常输出了 http://www.test.com/index.php 页面就会提示 " no input file specified."

nginx log

2016/04/07 11:33:54 [error] 22384#0: *27 FastCGI sent in stderr: "Unable to open primary script: /www/test/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: www.test.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "www.test.com"

nginx vhosts


server {
       listen   80; ## listen for ipv4; this line is default and implied
      #listen   [::]:80 default ipv6only=on; ## listen for ipv6

         root /www/test/; #你网站所在目录的绝对路径
          index index.php index.html index.htm; #目录索引

         # Make site accessible from http://localhost/
             server_name  www.test.com; #网站的域名

      location / {
                 index index.html index.htm index.php;  #目录索引
                 rewrite ^/(.*)$ /index.php/$1 last;  #Rewrite 隐藏index.php
       }

 #使nginx支持php
     location ~ ^(.+\.php)(.*)$ {
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

    }
 }

展开
收起
一枚小鲜肉帅哥 2020-05-27 18:41:05 1033 0
1 条回答
写回答
取消 提交回答
  • 菜不可及的程序猿

    "

    <span style=""font-family:Verdana, sans-serif, 宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;""><span style=""font-family:Verdana, sans-serif, 宋体;font-size:14px;line-height:22px;background-color:#FFFFFF;"">#fastcgi_pass 127.0.0.1:9000;

    #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    这两行注释了哈

    ######chmod 755 你的www-data目录"
    2020-05-28 10:03:55
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载