The two-level interface of the Discovery home page of the migration store shows a blank page, this HTTPS marketplace website
After modifying Nginx configuration, display normal
Add to
Location ~ [^/]\.php (/|$) {
#fastcgi_pass remote_php_ip:9000;
Fastcgi_pass Unix:/dev/shm/php-cgi.sock;
Fastcgi_index index.php;
Include fastcgi.conf;
fastcgi_split_path_info ^ (. +\.php) (/.+) $;
Fastcgi_param path_info $fastcgi _path_info;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
}
This configuration means that the. php file accessed in the browser is actually read by the. php file $document _root (Web root)-that is, when accessing 127.0.0.1/ index.php, you need to read the site root directory under the index.php file, if you do not configure this configuration item, Nginx does not go back to the site root directory access. php file, so return blank
Nginx+php Four common, important configuration itemsFastcgi_pass
Role: Nginx itself does not handle PHP requests, configuration files in the. PHP end of the request through fashcgi to PHP-FPM processing, PHP-FPM is a fastcgi manager of PHP
Scope: Location, if in location
Set the FASTCGI service with a value that can be a domain name, IP address: port, or a UNIX socket file.
Nginx connects fastcgi in 2 ways: TCP and UNIX domain sockets
TCP is connected using TCP ports 127.0.0.1:9000
Sockets are socket/dev/shm/php-cgi.sock using UNIX domain sockets (many tutorials use the path/tmp, and Path/dev/shm is a tmpfs, much faster than disk)
# TCP Form pass Fastcgi_pass localhost:9000;# socket form Pass Fastcgi_pass unix:/tmp/fastcgi.socket;# passed to cluster upstream cloud { Server cgi_1.cloud.com; Server cgi_2.cloud.com;} Fastcgi_pass Cloud;
Fastcgi_param
Scope: HTTP, server, location
Sets a parameter that is passed to the FASTCGI service, which can be either text or a variable.
# For example, on the access Layer Nginx pass the following 5 parameters Fastcgi_param remote_addr $remote _addr;fastcgi_param remote_port $remote _port;fastcgi_param server_addr $server _addr;fastcgi_param server_port $server _port;fastcgi_ param server_name $server _name;# so on fastcgi, for example php-cgi above can be obtained by $_server this super global variable. $_server[' remote_addr ']$_server[' remote_port ']$_server[' server_addr "]$_server[' server_port ']$_SERVER[' SERVER_ NAME ']
Fastcgi_param file details
Fastcgi_param script_filename $document _root$fastcgi_script_name; #脚本文件请求的路径, that is, when visiting 127.0.0.1/ index.php, you need to read the site root directory under the index.php file, if you do not configure this configuration item, Nginx does not go back to the site root directory access. php file, so return blank Fastcgi_param query_string $query _string; #请求的参数, such as App=123fastcgi_param Request_method $request _method; #请求的动作 (get,post) fastcgi_param content_type $content _type; #请求头中的Content-type field Fastcgi_param content_length $content _length; #请求头中的Content the-length field. Fastcgi_param script_name $fastcgi _script_name; #脚本名称 fastcgi_param Request_uri $request _uri; #请求的地址不带参数fastcgi_param Document_uri $document _uri; #与 $uri the same. Fastcgi_param document_root $document _root; #网站的根目录. The value specified in the root directive in the SERVER configuration Fastcgi_param server_protocol $server _protocol; #请求使用的协议, usually http/1.0 or http/1.1. Fastcgi_param Gateway_interface cgi/1.1; #cgi version Fastcgi_paRam Server_software nginx/$nginx _version; #nginx version number, you can modify, hide Fastcgi_param remote_addr $remote _addr; #客户端IPfastcgi_param Remote_port $remote _port; #客户端端口fastcgi_param server_addr $server _addr; #服务器IP地址fastcgi_param server_port $server _port; #服务器端口fastcgi_param server_name $server _name; #服务器名, the domain name specified in the server configuration Server_namefastcgi_param path_info $path _info; #可自定义变量-PHP only, required if PHP is built with--enable-force-cgi-redirectfastcgi_param Redirect_status 200;
Fastcgi_index
Scope: HTTP, server, location
When the request /
ends, the request is passed to the set index.php file for processing.
Fastcgi_index Index.php;fastcgi_param Script_filename/home/www/scripts/php$fastcgi_script_name;
Fastcgi_split_path_info
Scope: Location
Nginx does not get the value of Path_info by default, it has to be assigned by specifying a regular expression defined by Fastcgi_split_path_info $fastcgi_path_info
.
Purpose: to allow PHP to parse URLs like this http://www.xxx.com/index.php/abc/def
By default, when we open this URL, the page cannot be found. This will need to do path_info setup in Nginx.
principle: The index.php as php execution script, the/abc/def as a parameter passed to php-cgi execution.
implementation:Nginx version 0.7.31 support Fastcgi_split_path_info, this instruction can be set script_filename and Path_info variables, using regular expressions to separate the two parts.
Example: We add the following code to the Nginx configuration file "local" block.
Location ~ [^/]\.php (/|$) {#fastcgi_pass Remote_php_ip:9000;fastcgi_pass Unix:/dev/shm/php-cgi.sock;fastcgi_index Index.php;include fastcgi.conf;fastcgi_split_path_info ^ (. +\.php) (/.+) $;fastcgi_param path_info $fastcgi _path_info ; Fastcgi_param script_filename $document _root$fastcgi_script_name;} Restart Nginx Service/usr/local/nginx/sbin/nginx-s Reload
When Nginx processes the HTTP://WWW.XXX.COM/INDEX.PHP/ABC/DEF request, it will "index.php" as the PHP script,/abc/def as the index.php script parameters submitted to php-cgi execution.
Solve the problem of nginx+php level two page display blank