zoukankan      html  css  js  c++  java
  • 在使用vagrant访问PHP文件是报错“file not found”,好像是最新的NGINX不能识别document_root,只能改为自己的项目目录/vagrant_data

    出现该错误有很多可能,有可能是root配置不对,有可能是fastcgi_param SCRIPT_FILENAME参数不对等。

    而本人遇到的也是参数不对,但是是一个比较少人提及的问题,nginx版本不对。

    之前在nginx/1.10.1 或者 nginx/1.12.2里面都是这么写该参数:

    fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;

    然后我最近一次在ubuntu装nginx/1.4.6 (Ubuntu)却不行,出现了File not found,按照其他人的经验配置也不行。

    于是我写死了该目录:

    fastcgi_param SCRIPT_FILENAME /var/www/abc$fastcgi_script_name;

    其中/var/www/abc既是我的项目目录。

    所以可能版本较新nginx/1.4.6 (Ubuntu) ,现在$document_root已经被摒弃或者改为其他表现方式,或者需要自己手动配置,暂时不得而知,还在研究中,先让项目跑起来再说。

    server {
        listen       80;
        server_name  localhost;
    
        #charset koi8-r;
        #access_log  /var/log/nginx/host.access.log  main;
    
        location / {
            root   /vagrant_data;
            index index.php  index.html index.htm;
        }
    
        #error_page  404              /404.html;
    
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ .php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
    
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ .php$ {
        #    root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME /vagrant_data$fastcgi_script_name;
            #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #    deny  all;
        #}
    }
    


    ---------------------
    作者:stephen one
    来源:CSDN
    原文:https://blog.csdn.net/qq_39399594/article/details/82706968
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    Ubuntu 16.04安装迅雷(兼容性不高)
    Ubuntu 16.04安装QQ(不一定成功)
    Ubuntu查看隐藏文件夹的方法
    Ubuntu下非常规方法安装绿色软件(压缩包)
    Ubuntu下常规方法安装软件
    Ubuntu 16.04下截图工具Shutter
    java中 awt Graphics2D
    Vue2.0总结———vue使用过程常见的一些问题
    MySQL 中隔离级别 RC 与 RR 的区别
    DBAplus社群线上分享----Sharding-Sphere之Proxy初探
  • 原文地址:https://www.cnblogs.com/lxwphp/p/11123495.html
Copyright © 2011-2022 走看看