October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Fix “No Input File Specified” on Nginx with PHP-FPM

A practical Nginx and PHP-FPM troubleshooting guide: correct SCRIPT_FILENAME, reject missing scripts before FastCGI, verify backend permissions, and diagnose PATH_INFO and load-balanced deployments.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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/extra is 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:

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:

  • root is the absolute directory that actually contains the public PHP entry point.
  • $fastcgi_script_name is the script portion of the request URI.
  • $document_root$fastcgi_script_name produces the filesystem path PHP-FPM should open.
  • try_files $uri =404; runs before fastcgi_pass, so a missing script is rejected by Nginx.
  • Only one active SCRIPT_FILENAME assignment 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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_FILENAME mapping 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Validate the change before reloading

  1. Save a backup of the active virtual-host configuration.
  2. Run the platform’s Nginx configuration test, commonly nginx -t. Fix every syntax or include error before proceeding.
  3. Reload Nginx only after the test passes. A reload applies the new workers without unnecessarily stopping the service.
  4. Request a known PHP file and record the HTTP status and response.
  5. Request a deliberately nonexistent PHP file. It should return 404 from Nginx rather than “No input file specified.”
  6. If PATH_INFO is supported, test a valid script with a suffix and a suffix attached to a nonexistent script.
  7. 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Defining 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A 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_FILENAME assignment in the active includes.
  • Keep exactly one authoritative assignment.
  • Add try_files $uri =404; before fastcgi_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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.