美文网首页
nginx之fastcgi_params

nginx之fastcgi_params

作者: 词穷又词贫 | 来源:发表于2017-03-29 13:20 被阅读1104次
    location配置:
    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;      
        include        fastcgi_params;
    }
    
    yum方式安装nginx

    fastcgi_params:

    ===QUERY_STRING:                空
    ===REQUEST_METHOD:         GET
    ===CONTENT_TYPE:               空
    ===CONTENT_LENGTH:          空
    ===SCRIPT_NAME:                  /index.php
    ===REQUEST_URI:                  /index.php
    ===DOCUMENT_URI:              /index.php
    ===DOCUMENT_ROOT:          /etc/nginx/html
    ===SERVER_PROTOCOL:      HTTP/1.1
    ===REQUEST_SCHEME:        http
    ===HTTPS:                               空
    ===GATEWAY_INTERFACE:   CGI/1.1
    ===SERVER_SOFTWARE:     nginx/1.10.3
    ===REMOTE_ADDR:              192.168.9.215
    ===REMOTE_PORT:               3189
    ===SERVER_ADDR:               192.168.1.154
    ===SERVER_PORT:                80
    ===SERVER_NAME:               localhost
    

    需要修改:
    fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; 才可以访问到php程序文件
    不能使用$document_root ,$document_root是指/etc/nginx/html

    源码编译安装nginx
    location ~ .+\.php($|/) {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param PATH_INFO /$fastcgi_path_info;
        include www.lbd.com.fcgi.conf;
    }
    

    源码编译安装的nginx可以使用路径转换的变量来实现,可以使用$document_root


    相关文章

      网友评论

          本文标题:nginx之fastcgi_params

          本文链接:https://www.haomeiwen.com/subject/vcktottx.html