Windows 10下NGINX+PHP+FastCGI报错“No input file specified”求助
Hey KellyM, I’ve been there too—this error can be so frustrating when you’ve tried all the obvious fixes already. Let’s dig into some Windows-specific tweaks that might be the missing piece for you:
Don’t overlook Windows file permissions
Unlike Linux, Windows’ permission model is easy to miss. Make sure the user running Nginx (default isNT AUTHORITY\SYSTEM, or a custom user if you set one) has Read & Execute, List Folder Contents, and Read permissions for:- Your entire PHP application directory
- The PHP interpreter’s installation folder
To set this: Right-click your project folder → Properties → Security → Edit → Add the Nginx user (typeNT AUTHORITY\SYSTEMif using the default) → Apply permissions to all subfiles/folders.
Validate path formats and FastCGI alignment
Windows handles paths differently, so double-check these:- Use forward slashes in Nginx’s
rootdirective (e.g.,root C:/web/myapp/public;instead ofC:\web\myapp\public—Nginx can parse backslashes, but forward slashes avoid escape character issues). - Confirm
fastcgi_passmatches your PHP-FPM listen config. On Windows, PHP-FPM defaults to127.0.0.1:9000—make sure the PHP-FPM service is running (check Services for "PHP FastCGI Process Manager").
- Use forward slashes in Nginx’s
Lock down your index and try_files logic
- Ensure
index.phpis first in yourindexdirective:index index.php index.html index.htm; - If your app uses a single entry point (like Laravel’s
public/index.php), make surerootpoints directly to thepublicfolder, and add this location block to route all requests through the entry file:location / { try_files $uri $uri/ /index.php?$query_string; }
- Ensure
Audit PHP-FPM’s www.conf settings
Openwww.conf(usually in[PHP安装目录]/php-fpm.d/) and verify:listen = 127.0.0.1:9000matches what’s in your Nginx config.userandgroupare set to the same user running Nginx (default isNT AUTHORITY\SYSTEM).- Comment out any
php_admin_value[doc_root]line—this can override Nginx’sdocument_rootand cause path mismatches.
Test with a minimal configuration
Strip down your Nginx server block to the basics to rule out conflicting rules:server { listen 80; server_name localhost; root C:/web/myapp/public; index index.php index.html; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } }Create a simple
info.phpfile (<?php phpinfo(); ?>) in your root folder, restart Nginx and PHP-FPM, then visithttp://localhost/info.php. If this works, gradually re-add your original config lines to find the conflicting setting.
内容的提问来源于stack exchange,提问作者KellyM

