Error Log
Install nginx-1.0.5 and php-5.3.6 (php-fpm) Can't Wait To test info. php? Php phpinfo () ;?> ), However, only blank pages are returned and nothing is output. The following is an error log.
192.168.6.82--[01/Aug/2011: 13: 54: 20 + 0800] "GET/info. php HTTP/1.1 "404 5"-"" Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv: 1.9.2.9) Gecko/20100827 Red Hat/3.6.9-2. el6 Firefox/3.6.9"
192.168.6.82--[01/Aug/2011: 14: 57: 30 + 0800] "HEAD/info. php HTTP/1.1 "404 0"-"" curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.12.6.2 zlib/1.2.3 libidn/1.18 libssh2/1.2.2"
192.168.6.82--[01/Aug/2011: 13: 58: 57 + 0800] "GET/index.html HTTP/1.1" 200 151 "-" "Mozilla/5.0 (X11; U; linux x86_64; zh-CN; rv: 1.9.2.9) Gecko/20100827 Red Hat/3.6.9-2. el6 Firefox/3.6.9"
Analysis
1. Use firefox to browse the http: // 192.168.5.87/info. php test page and return a blank page.
2. Use curl to test http: // 192.168.5.87/info. php. The test page prompts 404 Not found.
# Curl-I http: // 192.168.5.87/info. php
HTTP/1.1 404 Not Found
Server: nginx/1.0.5
Date: Mon, 01 Aug 2011 06:54:46 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.3.6
3 use firefox to browse http: // 192.168.5.87/index.html
4. The index.html on the static page can be accessed, while the dynamic info. php is indeed 404 inaccessible. Why? The index.html file directory is the default installation directory of nginx/usr/local/nginx/html, while
Info. php I put it under/data/web. Is that the reason? See the nginx. conf configuration document.
Server {
Listen 80;
Server_name localhost;
Location /{
Index index.html index.htm;
Root html;
}
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}
Location ~ \. Php $ {
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
Include fastcgi_params;
}
}
Process
Try to change
Location ~ \. Php $ {
Root/data/web;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
Include fastcgi_params;
}
Nginx-t & nginx-s reload
Test Access still does not work
Google
Change again
Location ~ \. Php $ {
Root/data/web;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/data/web $ fastcgi_script_name;
Include fastcgi_params;
}
Nginx-t & nginx-s reload
Test
[Root @ me zongm] # curl-I http: // 192.168.5.87/info. php
HTTP/1.1 200 OK
Server: nginx/1.0.5
Date: Mon, 01 Aug 2011 08:34:17 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.3.6
Firefox test OK!
Summary
The problem is that in the configuration document, it is estimated that many of my friends will encounter php output blank pages that do not display anything,
This is mainly because the nginx root command or fastcgi_param command has been configured. For more information, see here!
Let's take a look at the nginx. conf configuration file,
Server {
Location /{
Index index.html index.htm;
Root html;
}
Location =/50x.html {
Root html
}
Location ~ \. Php $ {
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
Include fastcgi_params;
}
}
1 found in addition to location ~ In addition to \. php $, each location has a root command to load the root directory of the web file. The default value is/usr/local/nginx/html. The first error is not in location ~ \. Php $ Add the web file root directory
Root/data/web;
Or add a root field under the server field, for example
Server {
.........
Root/data/web;
.........
}
2. You can see that the SCRIPT_FILENAME parameter of the fastcgi_param command in PHP determines which script to execute. Therefore, you must change the location
Fastcgi_param SCRIPT_FILENAME/data/web $ fastcgi_script_name;