Home  >  Article  >  Backend Development  >  nginx php blank page fastcgi_param_PHP tutorial

nginx php blank page fastcgi_param_PHP tutorial

WBOY
WBOYOriginal
2016-07-22 09:02:39882browse

After installing nginx today, I found that the html page can be browsed normally, but when the php file page is opened, it is blank. I looked at the php-fpm log and the nginx log and found no problem

After searching online for a long time, I finally found the solution. I will make a note here

A saying on the Internet is that such a sentence is missing in the nginx configuration file

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

What is this sentence for? In fact, it is to define the server variables used in php, which is $_SERVER

http://wiki.nginx.org/NginxHttpFcgiModule There is such a sentence under this website

This module allows Nginx to interact with FastCGI processes and control what parameters are passed to the process.

In fact, it means that the server passes some parameters it needs to your cgi that processes php, and php must have at least the following two parameters before it can be executed

Below is an example of the minimally necessary parameters for PHP:

fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name;

fastcgi_param QUERY_STRING $query_string;

Parameter SCRIPT_FILENAME is used by PHP for determining the name of script to execute, and QUERY_STRING contains the parameters of the request.

So when we don’t define the SCRIPT_FILENAME system variable, php cannot interpret and execute it

The definition of this variable can be written in the nginx configuration file nginx.conf, or it can be written externally and included in nginx.conf using include.

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/371849.htmlTechArticle After installing nginx today, I found that the html page can be browsed normally, but the page of the php file is blank when I opened it. I looked at the php-fpm log and the nginx log and couldn't find the problem. I searched online for a long time and finally...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn