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
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    CodeForces Gym 100500A A. Poetry Challenge DFS
    CDOJ 486 Good Morning 傻逼题
    CDOJ 483 Data Structure Problem DFS
    CDOJ 482 Charitable Exchange bfs
    CDOJ 481 Apparent Magnitude 水题
    Codeforces Gym 100637G G. #TheDress 暴力
    Gym 100637F F. The Pool for Lucky Ones 暴力
    Codeforces Gym 100637B B. Lunch 找规律
    Codeforces Gym 100637A A. Nano alarm-clocks 前缀和
    TC SRM 663 div2 B AABB 逆推
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15453279.html
Copyright © 2011-2022 走看看