iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
A PHP 404 in NGINX has two possible owners: NGINX may fail to map the URL to a file, or NGINX may pass a path to PHP-FPM that PHP cannot see. Find out which process generated the response before changing directives. Record the exact URL and Host header, inspect the active configuration with nginx -T, verify the file at the resulting absolute path, and compare that path with SCRIPT_FILENAME. In most installations, the durable fix is a correct root or alias, a PHP location that reaches the intended FPM endpoint, and a matching SCRIPT_FILENAME, with try_files $fastcgi_script_name =404 used after the path mapping is proven.
What a PHP 404 from NGINX actually means
NGINX can return a 404 before PHP runs. Its request processing maps the URI to a filesystem path using the applicable root or alias. If the resulting file is absent, NGINX can send a 404 itself. The NGINX Beginner’s Guide describes this behavior and recommends checking the access and error logs when the result is unexpected.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
A second failure occurs after NGINX selects a PHP location and sends the request to PHP-FPM. PHP-FPM uses the FastCGI SCRIPT_FILENAME parameter to decide which script to open. If that parameter names a path that is wrong, unavailable in the FPM environment, or points to a directory instead of the requested script, the response may say No input file specified, Primary script unknown, or appear as a PHP-generated 404.
These cases look similar in a browser but require different repairs. A missing file under the active NGINX root is not fixed by changing the FPM socket, and a path mismatch between containers is not fixed by adding another rewrite.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
Capture evidence before editing the configuration
Start with one reproducible request. Do not test a different hostname, path, or protocol while diagnosing the original failure.
- Write down the complete request. Include the scheme, hostname, port, URI, query string, and the
Hostheader. The hostname determines whichserverblock NGINX selects. - Repeat it with headers visible. For example, run
curl -i https://example.test/path/script.php?x=1(substitute the real host and URI). Save the status,Server,Content-Type, redirects, and response body. - Watch the matching logs. Note the access-log line and the error-log line generated at the same time. A 404 logged by NGINX before an upstream request indicates a different problem from a response returned by PHP-FPM.
- Dump the running configuration. With the necessary privileges, run
nginx -T. This prints included files as well as the main file, so you can find the effectiveserverblock,rootoralias, regex PHP location,try_files,fastcgi_pass, andSCRIPT_FILENAME. - Check the candidate file directly. Use the shell to test the absolute path implied by the active mapping. Check spelling and case, symlinks, release-directory links, and URI prefixes. A file that exists in your editor’s project directory may not exist under the directory NGINX is serving.
Keep a known-good static file in the same document tree. If that static file also returns 404, concentrate on server selection and filesystem mapping before investigating PHP.
Recommended Free Tools
Understand how root, alias, and try_files build the path
The path calculation is the center of this problem. NGINX combines the URI with the filesystem base defined in the context that matches the request. try_files then checks one or more candidate files or directories and either continues, internally redirects, or ends the request with a status such as =404.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
root appends the URI
With this configuration:
root /var/www/example/public;
a request for /admin/report.php is normally checked as /var/www/example/public/admin/report.php. A request for / is checked as a directory, after which the configured index handling may select an index file.
alias replaces the matching location prefix
An alias maps a location to a different directory or file. For example:
location /assets/ {
alias /srv/site-assets/;
}
The URI /assets/app.css maps to /srv/site-assets/app.css, not to /srv/site-assets/assets/app.css. A missing or extra trailing slash, or an alias used in a regular-expression location without the required capture, can produce a path that looks plausible but does not exist.
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 minuteRank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
| Directive | How the filesystem path is formed | Typical mistake |
|---|---|---|
root /var/www/site; |
Base directory plus the request URI | Using a project root when the public directory is the real web root |
alias /srv/files/; in location /downloads/ |
Replace the matching /downloads/ prefix with /srv/files/ |
Expecting NGINX to append the location prefix again |
try_files $uri $uri/ /index.php?$query_string; |
Check the URI as a file, then directory, then internally redirect | Letting a typo fall through to a front controller and hiding the original path error |
try_files $fastcgi_script_name =404; in a PHP location |
Check the script selected for FastCGI before forwarding | Adding it before fixing the root/alias, so every valid script is rejected |
Check the exact location that won
NGINX location selection is not based only on the order in which blocks appear. Exact, prefix, and regular-expression locations interact, and a regex block such as location ~ .php$ may handle a request that you expected a prefix block to handle. The output of nginx -T, together with a fresh log line, is more reliable than looking at one configuration file in isolation.
Use a PHP location that maps and forwards the same script
A conventional setup has a document root, a front-controller fallback for ordinary application routes, and a separate PHP location. Adapt the root, socket, and index names to your deployment:
server {
root /var/www/example/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
}
This pattern has four separate responsibilities:
- URI routing: The first
try_filespreserves real files and directories, then intentionally sends application routes to/index.phpwith the original query string. - Script existence: The PHP-location
try_filesstops a nonexistent script before it reaches PHP-FPM. It should be added after you have proved that the candidate path is correct. - Script identity:
SCRIPT_FILENAMEtells PHP the absolute file to open. NGINX documents the common document-root form$document_root$fastcgi_script_name, as well as configurations that use an explicit absolute base path. - Upstream transport:
fastcgi_passselects the PHP-FPM Unix socket, host, or TCP port. The exact socket filename is distribution- and deployment-specific.
Do not copy the socket path blindly. Confirm that the file exists or that the configured host and port are reachable, and confirm that the active PHP-FPM pool is the one listening there. An incorrect endpoint more commonly causes a 502 Bad Gateway than a 404, but it must be ruled out when several errors appear during a change.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
Slash-ending requests and index files
A request ending in / is not the same as a request ending in .php. If fastcgi_index index.php is configured, NGINX appends index.php to a slash-ending URI while constructing $fastcgi_script_name. Verify that the resulting index file exists under the active root and that the PHP location receives it. A missing index or an unexpected directory mapping can otherwise look like a generic PHP 404.
Fix the common path-mapping failures
The active root is not the directory containing the script
Applications often keep source files above a public directory, or deploy each release into a timestamped directory with a symlink named current. If NGINX points at /var/www/app while the public script is in /var/www/app/public/index.php, the URI /index.php will be checked in the wrong place. Set the root to the directory that should be web-accessible, then verify the exact resulting path from the shell.
An alias adds or removes a path segment
With aliases, compare the location prefix and replacement directory character by character. Pay particular attention to trailing slashes and regex captures. A PHP location that uses an alias must also construct SCRIPT_FILENAME for the aliased file; blindly concatenating $document_root and $fastcgi_script_name can name a path under the root rather than the alias target. Use an explicit, tested mapping for the alias and confirm what PHP-FPM can see.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
A front-controller fallback masks a typo
try_files $uri $uri/ /index.php?$query_string; is intentional for frameworks that route application URLs through index.php. It is not proof that every requested PHP filename exists. If a misspelled script is internally redirected to the front controller, the application may emit its own 404, making the original typo harder to diagnose. Test the literal PHP URI and inspect the internal routing logic before changing the fallback.
SCRIPT_FILENAME is incomplete or duplicated
The parameter must be one absolute filename. Common errors include sending only $fastcgi_script_name without a base directory, concatenating a root that already contains the URI prefix, or using a hard-coded path from a different release. Logically derive the value for one failing URI, then check that exact path. NGINX’s documented principle is that PHP uses SCRIPT_FILENAME to determine the script name.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →NGINX and PHP-FPM do not share the same filesystem
In containers, chroots, or separate hosts, NGINX may see /var/www/example/public/index.php while PHP-FPM sees the application at /app/public/index.php. The path can pass NGINX’s existence check and still fail in PHP, or fail at NGINX if the mount is absent there. Mount the application at a consistent absolute path, or deliberately translate the path so the value sent in SCRIPT_FILENAME is valid inside the FPM environment. Test from both processes’ environments rather than from the host alone.
A safe, repeatable repair procedure
- Freeze the failing example. Keep one exact URL, hostname, and request method. Record the current status and response body with
curl -i. - Identify the selected server. Use
nginx -Tand the request’sHostvalue to locate the activeserverblock. Check for a more specific server name, port, or default server that could be receiving the request instead. - Trace the URI to a file. Apply the active
rootoraliasto the URI manually. Include any prefix replacement, regex capture, symlink, and release-directory link. Confirm the file’s case and permissions. - Inspect both
try_filesdirectives. Determine whether NGINX checks the literal URI, a directory, a front-controller fallback, or$fastcgi_script_name. Temporarily reason through each candidate instead of adding more fallbacks. - Validate the FastCGI endpoint. Confirm the Unix socket file or TCP listener and the PHP-FPM pool that owns it. A wrong endpoint is a separate fault from a wrong script path.
- Derive
SCRIPT_FILENAME. For the failing URI, write down the final value produced by the configured variables. Verify that the same absolute path is readable by PHP-FPM, especially when containers or chroots are involved. - Add the early existence check. Once mapping is correct, use
try_files $fastcgi_script_name =404;in the PHP location. This keeps nonexistent scripts from being forwarded and makes the failure belong clearly to NGINX. - Validate syntax before reloading. Run the platform’s NGINX configuration test, commonly
nginx -t, and reload only after it succeeds. A syntax failure leaves the old configuration active; do not assume an edit took effect. - Retest and inspect fresh lines. Repeat the exact
curl -irequest, then compare the new access and error logs with the original. Test a known-good static file, a known-good PHP file, a missing PHP file, and the application’s intended front-controller route. - Remove diagnostics. If you created an
info.php-style file or other test endpoint, delete it or restrict it immediately after testing. Diagnostic PHP files expose environment details.
Interpret the symptom you receive
| Observed result | Most useful first check | What the result usually indicates |
|---|---|---|
| NGINX-branded 404 with no PHP application headers | Active server block, root/alias, and the literal file path | NGINX rejected the URI before PHP-FPM ran |
| “No input file specified” | The absolute value of SCRIPT_FILENAME inside the FPM environment |
PHP-FPM could not open the script named by FastCGI |
| “Primary script unknown” | Path translation, container mounts, chroot settings, and filename case | The upstream PHP runtime does not recognize the requested script path |
| Application-generated 404 after a front-controller redirect | The first try_files fallback and the query string |
NGINX may be working as configured, while the application route is unknown |
| 502 Bad Gateway while changing PHP settings | fastcgi_pass, socket existence, listener address, and FPM health |
NGINX could not communicate with the configured PHP-FPM endpoint; this is not normally a missing-file 404 |
Headers and logs are more trustworthy than the browser’s generic error page. A reverse proxy, CDN, or application middleware can replace the body, so correlate the response with the NGINX access log and the PHP-FPM log where available.
How to compare two proposed fixes
When someone suggests changing the root, adding a rewrite, or replacing SCRIPT_FILENAME, evaluate the proposal against these questions:
- Path correctness: Does the request URI resolve to the real file under the selected root or alias?
- Failure ownership: Does NGINX reject a missing script with
try_files, or is the request being sent to PHP-FPM first? - Runtime visibility: Can PHP-FPM open the same absolute path, including across containers, chroots, and symlinked releases?
- Fallback intent: Is
/index.phpan intentional application route, or is it hiding a misspelled filename? - Observability: Will the logs make the selected location and resolved path clear after the change?
A fix that only changes the visible status code, adds a broad rewrite, or points every request at a front controller has not necessarily repaired PHP script resolution. The configuration is correct when the intended URI maps to the intended file, PHP-FPM receives an absolute path valid in its own environment, and missing scripts fail early and predictably.
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.

