“No input file specified” means PHP-FPM cannot open the script path Nginx sent in SCRIPT_FILENAME. The reliable fix is to make the document root explicit, define SCRIPT_FILENAME exactly once, reject missing scripts with try_files $uri =404;, and verify that the PHP-FPM worker can read the resulting path. Then test the active Nginx configuration and inspect both Nginx and PHP-FPM logs.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What “No input file specified” actually means
Nginx does not execute a PHP file itself. It converts the request URI into FastCGI parameters and sends the request to a PHP-FPM pool. PHP-FPM then tries to open the filesystem path in SCRIPT_FILENAME. If that path is wrong, does not exist, or cannot be traversed or read by the PHP-FPM process, the worker returns “No input file specified.”
As an Amazon Associate I earn from qualifying purchases.
This is different from an ordinary missing-page response. Without an existence check, Nginx can forward a request for a nonexistent script to PHP-FPM, leaving the backend to report the problem. A correct configuration makes Nginx return a normal 404 before FastCGI for scripts that are not present.
- Wrong document root: Nginx points at a directory other than the application’s real public directory.
- URI-to-file mismatch: The requested URI does not map to the file path being passed to PHP.
- Duplicate parameters: Two configuration files define
SCRIPT_FILENAME, and PHP receives an unintended value. - Missing deployment artifact: The file exists on one machine but not on the host running PHP-FPM.
- Permission or traversal failure: The PHP-FPM user cannot enter a parent directory or read the script.
- PATH_INFO confusion: A URL such as
/script.php/extrais turned into a fabricated filename instead of separating the script from the extra path.
Use this known-good configuration shape first
Start with the smallest configuration that establishes one root, one script-path mapping, an existence check, and a working PHP-FPM endpoint:
#1 Best Overall
server {
root /var/www/example/public;
location ~ .php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
}
Replace the root and socket with the values used by your distribution and application. The important relationships are more significant than the literal paths:
rootis the absolute directory that actually contains the public PHP entry point.$fastcgi_script_nameis the script portion of the request URI.$document_root$fastcgi_script_nameproduces the filesystem path PHP-FPM should open.try_files $uri =404;runs beforefastcgi_pass, so a missing script is rejected by Nginx.- Only one active
SCRIPT_FILENAMEassignment is present.
If the included file already defines SCRIPT_FILENAME, do not add the explicit line shown above as a second definition. Choose one authoritative method and remove the other.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Repair the configuration in the right order
1. Confirm the active server root
Find the server block that handles the failing hostname and identify its effective root. Do not assume that the directory in a deployment script, shell prompt, or separate virtual host is the one Nginx uses. The root must be the directory from which the requested public URI is served.
For a request to /index.php with root /var/www/example/public;, the expected script path is:
/var/www/example/public/index.php
Check the mapping directly on the PHP-FPM host:
ls -l /var/www/example/public/index.php
namei -l /var/www/example/public/index.php
namei -l is useful because a file may be readable while one of its parent directories lacks execute permission. If the file is in a release directory, check that the Nginx configuration points to the currently deployed release or to a symlink whose target exists on that machine.
2. Locate every SCRIPT_FILENAME definition
Nginx combines directives from the main configuration, included files, and nested locations. Search all enabled configuration files for the parameter and read the surrounding include statements. A common failure is to include a file that already supplies SCRIPT_FILENAME and then append a second custom value.
Recommended Free Tools
Rank #2
As Maxim Dounin explained, an included fastcgi.conf can already contain this parameter; adding another one sends two values to PHP, with only one being correct. Depending on the FastCGI and PHP versions, the wrong value may be selected, so the configuration can look plausible while still producing the error.
Use one of these patterns, not a mixture:
- Included definition: include the distribution’s file that contains the correct
SCRIPT_FILENAMEmapping and do not redefine it locally. - Explicit definition: include a parameter file that does not define it, then set
fastcgi_param SCRIPT_FILENAME ...;once in the PHP location.
Do not try to fix a duplicate by changing the order of two definitions. Removing the ambiguity is safer than relying on which duplicate a particular stack uses.
3. Reject nonexistent scripts before FastCGI
Place the check inside the PHP location and before fastcgi_pass:
try_files $uri =404;
For a request whose URI does not name a real file under the configured root, Nginx now returns HTTP 404 and PHP-FPM is never contacted. This prevents a backend “No input file specified” response from masking a straightforward missing-file condition.
Do not replace this with a check that tests a different directory, and do not put it in a location that the failing request never enters. A front-controller application is a separate case: its non-file routes should be internally routed to the real entry script, while direct requests for missing .php files should still be rejected.
4. Verify the PHP-FPM endpoint and pool
The fastcgi_pass target must be the pool serving this virtual host. It may be a Unix socket such as unix:/run/php/php-fpm.sock or a TCP address and port. A wrong endpoint usually causes a connection error rather than “No input file specified,” but checking it now prevents you from debugging the wrong pool.
Confirm that the socket exists and that its owner and group permit Nginx to connect. For a TCP pool, confirm that PHP-FPM is listening on the configured address and port. Then identify the PHP-FPM worker user from the pool configuration; that user, not your interactive shell account, needs access to the script path.
5. Check access to the complete path
PHP-FPM must be able to traverse every parent directory and read the script. Test the path as the pool user where your operating system permits it:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
sudo -u www-data test -r /var/www/example/public/index.php && echo readable
sudo -u www-data namei -l /var/www/example/public/index.php
The account may differ from www-data; use the actual pool user. Correct the directory execute permissions, file read permissions, ownership, or security policy as appropriate. Avoid making the entire application world-writable merely to silence this error.
In containerized or restricted deployments, also check the mount namespace and filesystem policy. A path visible to an Nginx container is not automatically visible to a separate PHP-FPM container, and a host path is irrelevant if it is not mounted at the same location inside the PHP-FPM environment.
6. Account for load-balanced deployments
The file must exist and be readable on the machine that runs PHP-FPM. In a load-balanced arrangement, Nginx can be healthy while a backend node lacks the current release. A request routed to that node then produces the error even though the file is present on the Nginx host or on another PHP-FPM node.
Check every backend node, not just the one used for an interactive test. Keep release versions and document-root paths consistent, or use storage that is mounted and readable by all PHP-FPM workers. Health checks should verify application readiness, not merely that the FastCGI port accepts connections.
Rank #4
7. Treat PATH_INFO as a deliberate feature
A URL such as /script.php/extra contains a PHP script followed by PATH_INFO. If the location and parameter mapping treat the whole URI as a filename, PHP-FPM may be asked to open a nonexistent path such as /var/www/example/public/script.php/extra.
If the application needs PATH_INFO, split the script portion from the suffix and pass the suffix separately. A typical location uses a regular expression that captures the script and path information, then sets fastcgi_param PATH_INFO to the captured suffix. The exact expression must match your application’s URL rules; test both a valid script with PATH_INFO and an invalid script before deploying it.
PHP’s cgi.fix_pathinfo behavior can change how a malformed or ambiguous path is interpreted. Do not depend on an implicit fallback. Ensure that SCRIPT_FILENAME names the real .php file and that the application receives only the intended PATH_INFO value.
Understand the important configuration choices
| Choice | How the script path is derived | Missing-script behavior | PATH_INFO considerations | Main risk |
|---|---|---|---|---|
Explicit mapping with $document_root$fastcgi_script_name |
Nginx’s effective root plus the script URI | Safe when paired with try_files $uri =404; |
Works for ordinary .php URIs; requires deliberate splitting for PATH_INFO |
The root must be correct and must not be overridden in a nested location |
Included FastCGI file that defines SCRIPT_FILENAME |
Whatever mapping the included file supplies | Depends on whether try_files is also present |
Depends on the included file and surrounding location rules | Adding a second local definition creates duplicate parameters |
| Front-controller routing | Non-file requests are sent to one real entry script, commonly index.php |
Existing static files are served; application routes are internally redirected; direct missing PHP files should still return 404 | PATH_INFO is application-specific and must not be inferred accidentally | A broad rewrite can send a typo or malicious path to PHP instead of returning 404 |
| PATH_INFO-enabled location | The script capture becomes SCRIPT_FILENAME; the suffix becomes PATH_INFO |
Requires an existence check for the captured script | Supports URLs such as /script.php/extra when tested explicitly |
A fabricated combined filename or unsafe path-info handling |
The safest baseline for a conventional PHP site is an explicit, unambiguous script mapping plus an existence check. Add front-controller or PATH_INFO behavior only when the application requires it.
Free tools Windows power users keep installed
One-click scans. No signup required.
Front-controller applications: route requests without hiding errors
Many PHP applications expose one entry script and route clean URLs internally. In that design, a request such as /products/42 is not supposed to map to a physical file. The Nginx rule should distinguish existing files from application routes and then send the latter to the real entry point.
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
This pattern follows the established Nginx routing shape: serve a real file or directory when present, otherwise route the request to the application’s entry script while preserving the query string. The PHP location still rejects a direct request for a nonexistent PHP script. Do not use a catch-all rewrite that forwards every path, including mistyped PHP filenames, without an existence check.
Best Value
Validate the change before reloading
- Save a backup of the active virtual-host configuration.
- Run the platform’s Nginx configuration test, commonly
nginx -t. Fix every syntax or include error before proceeding. - Reload Nginx only after the test passes. A reload applies the new workers without unnecessarily stopping the service.
- Request a known PHP file and record the HTTP status and response.
- Request a deliberately nonexistent PHP file. It should return 404 from Nginx rather than “No input file specified.”
- If PATH_INFO is supported, test a valid script with a suffix and a suffix attached to a nonexistent script.
- Repeat the tests against each PHP-FPM backend when traffic is load-balanced.
Use the logs while making these requests. The Nginx error log can reveal the selected location, upstream connection, and filesystem failure. The PHP-FPM log can show the path the worker attempted to open, pool-level permission problems, and worker restrictions. Compare the logged path character by character with the path on disk; differences in release directories, duplicated prefixes, or unexpected suffixes usually identify the fault.
Common symptoms and targeted fixes
| Symptom | Likely cause | What to inspect |
|---|---|---|
| Every PHP URL returns “No input file specified” | Wrong server root or a globally incorrect SCRIPT_FILENAME |
The active virtual host, effective root, and the exact path logged by PHP-FPM |
| Only one virtual host fails | That host inherits or overrides a different root or include | Server and location inheritance, plus all included FastCGI files |
| Only nonexistent PHP files show the message | No pre-FastCGI existence check | Add try_files $uri =404; in the PHP location |
| The file exists, but PHP-FPM still cannot open it | Pool user lacks directory traversal or read permission | Each parent directory, file mode, ownership, and security confinement |
| It fails only after deployment | Backend nodes have different releases or mount paths | The file and root on every PHP-FPM host |
Plain PHP works, but /script.php/extra fails |
PATH_INFO is being appended to the filename | Location captures, SCRIPT_FILENAME, PATH_INFO, and cgi.fix_pathinfo |
| Changing the custom path has no effect | A second definition from an include is still active | Search for every fastcgi_param SCRIPT_FILENAME and remove the duplicate |
| Nginx reports an upstream connection error instead | Wrong socket, port, or socket permissions | fastcgi_pass, listener state, and socket access |
Configuration mistakes to avoid
Using a relative or guessed root
PHP-FPM needs an absolute filesystem path. A root copied from a development machine, an old release directory, or a repository checkout may not exist in production. Confirm the path in the running server block and on the backend that opens the file.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsDefining SCRIPT_FILENAME twice
This is one of the most deceptive errors because the configuration can pass a syntax test. The problem appears only when PHP receives the conflicting FastCGI parameters. Keep the definition in one place and document which include owns it.
Relying on fastcgi_index to repair a path
fastcgi_index does not correct an invalid script filename in this situation. As Maxim Dounin noted, “fastcgi_index is meaningless here.” The relevant controls are the location match, the effective root, the script-name mapping, and the existence check.
Forwarding every request to PHP
A broad rewrite may make an application appear to work while turning typos, probes, and missing scripts into backend requests. Keep static-file handling, application routing, and direct PHP execution separate enough that an absent script receives a predictable 404.
Testing only from the Nginx machine
A successful ls on the Nginx host proves nothing about a separate PHP-FPM host. Always verify the path from the worker’s filesystem and security context, especially after a release, container restart, or backend scale-out.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteA repeatable checklist
- Identify the exact server block handling the hostname.
- Confirm its absolute public document root.
- Map the failing URI to the expected script path manually.
- Check that the script exists on the PHP-FPM host.
- Check traversal and read access as the pool user.
- Find every
SCRIPT_FILENAMEassignment in the active includes. - Keep exactly one authoritative assignment.
- Add
try_files $uri =404;beforefastcgi_pass. - Verify the Unix socket or TCP endpoint belongs to the intended pool.
- Separate PATH_INFO from the script filename when the application needs it.
- Run the Nginx configuration test, reload, and repeat positive and negative requests.
- Check Nginx and PHP-FPM logs on every backend node.
When these checks agree, PHP-FPM receives the real script path, missing files are rejected at the web-server layer, and the “No input file specified” response is replaced by either the expected PHP response or a meaningful 404.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




