Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>
After configuring nginx, an error will appear when executing PHP file, and “no input file specified” will be displayed
Methods introduced online, such as modifying fastcgi_ The value of param instruction is absolute path, modifying php.ini file and so on are not the most fundamental solutions, and the key cause of the problem is not found
the root cause of “no input file specified” is the incorrect configuration of nginx, which leads to the error of CGI getting parameters . Simply put, it’s $document_ Root is not defined. In the configuration file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Is the instruction statement written in the location block (usually matching PHP)
We know that there are three levels of relationship in the configuration file of nginx, HTTP > server > location。 If you want to use $document in location_ Root, you need to define the root instruction in the upper server block or HTTP block, so that you can use $document in the location through the inheritance relationship_ Root gets the value of root. The root instruction value defined in another location is a local variable, and its value cannot be obtained in the location matching PHP
Therefore, the solution to this problem is to move the root in the “/” location up to in the server block. Or, redefines root in the location block of PHP
Similar Posts:
- Nginx Error: File not found [Use php-fpm to parse PHP]
- [Solved] Nginx-FastCGI-“Primary script unknown” while reading response header from upstream,
- Nginx+PHP FastCGI sent in stderr: “Primary script unknown” while reading response head…
- [Solved] Primary script unknown in nginx configuration PHP
- File not found error handling of nginx accessing PHP files, two cases
- PHP nginx 504 gateway timeout gateway timeout error
- nginx connect() failed (111: Connection refused) while connecting to upstream
- Wnmp environment configuration (Windows + nginx + MySQL + PHP)
- Fix Nginx 502 Error:upstream sent too big header while reading response header from upstream
- Error 500 when opening the site configured by nginx