nginx之fastcgi_params

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_第1张图片

你可能感兴趣的:(nginx之fastcgi_params)