Nginx + PHP - Aucun fichier d'entrée spécifié
Un message d'erreur Nginx + PHP courant "Aucun fichier d'entrée spécifié."
nginx.conf
http { include mime.types; default_type application/octet-stream; server { listen 80; server_name localhost; location / { root www; index index.html index.htm; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9999; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } }
Testé avec Nginx 1.12.1 + PHP 7.1
Solution
PHP n'a pas pu trouver le fichier.php
à exécuter, car le chemin du fichier racine danslocation / {}
ne s'applique pas auxlocation ~ \.php$
.
Pour le résoudre, déplacez le chemin du fichier racine vers le bloc serveur comme ceci:
nginx.conf
http { include mime.types; default_type application/octet-stream; server { listen 80; server_name localhost; # Move the root file path to server block. root www; location / { #root www; index index.html index.htm; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9999; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } }