Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsiTechGuides 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
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
If Nginx downloads a .php file, it is serving that request as static content. The request has not reached PHP-FPM through FastCGI, so the browser receives the source file instead of a generated response. Fix the Nginx server block so PHP requests reach the PHP-FPM listener that is actually running, and set SCRIPT_FILENAME to the real script path.
Start by inspecting the active configuration with nginx -T. Then check the PHP location, its matching rules, the site root, the PHP-FPM socket or TCP address, and the reload status. The procedure below covers normal single-site installs, front-controller applications, PATH_INFO URLs, containers, and common permission or path errors.
What a PHP download tells you
Nginx does not execute PHP itself. It serves static files and can route application requests to a FastCGI server such as PHP-FPM. A browser download means the request was handled by a static-content location, or that the PHP location exists but is not being selected. PHP-FPM therefore never received the script.
Changing the MIME type, adding a download header, or renaming the file does not solve the underlying problem. The request must be matched by a PHP location and forwarded with fastcgi_pass. PHP-FPM then uses FastCGI parameters, especially SCRIPT_FILENAME, to locate and execute the script.
#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: 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.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
Before changing configuration
- Identify the host name and URI that produce the download. Nginx may select a different virtual server when the
Hostheader does not match the intendedserver_name. - Find the document root containing the PHP file. The path must be the same path visible to PHP-FPM, not merely the path visible inside an Nginx container.
- Determine whether PHP-FPM listens on a Unix-domain socket or a TCP address. The configured endpoint must match the running pool exactly.
- Keep a shell session available for
nginx -t, service status checks, and log review. Do not expose diagnostic scripts or PHP source on a public site.
Use this diagnostic sequence
-
Inspect the active Nginx configuration
Run:
sudo nginx -TThis prints the configuration Nginx has loaded, including files included from directories such as
conf.dorsites-enabled. Search the output for the relevantserver_name,root, and anylocationthat handles.php. Looking only at an unused file can lead to a correct-looking edit that has no effect. -
Confirm the request reaches the intended virtual server
Check the exact host name in the browser and compare it with the active
server_name. A default server, an old site definition, or a duplicate name can receive the request first. Test a specific host when needed: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.curl -i -H 'Host: example.test' http://127.0.0.1/path/test.phpUse a non-sensitive test path. The response headers and the Nginx access log can show which server is answering.
-
Check that a PHP location exists and can be selected
A minimal PHP handler looks like this:
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; }The regular expression matches a URI ending in
.phpand, with the(?:/|$)suffix, also supports a path-info suffix such as/index.php/articles. Replace the socket with the endpoint used by the running PHP-FPM pool. -
Check location precedence
Nginx first finds the longest prefix location, then evaluates regular-expression locations unless a
^~prefix prevents that regex search. A broad prefix such aslocation ^~ /app/can therefore bypass the PHP regex and serve the script as a static file. Another regex location can also win before the PHP rule. Inspect every location in the selected server block, not just the PHP block. -
Verify the root and script path
In the same server or location context,
rootmust point to the directory that contains the requested file. With a request for/admin/status.phpand a root of/var/www/site, the expected script path is/var/www/site/admin/status.php. The usual parameter expression is: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.fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;Do not prepend
$document_roottwice. A value such as/var/www/site/var/www/site/admin/status.phpcauses PHP-FPM to report a missing script, often as “Primary script unknown” or “No input file specified.”Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack- 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
-
Confirm PHP-FPM is installed, running, and listening
Check the service using the service manager provided by your operating system, then inspect the pool configuration for its
listenvalue. Typical deployments use a versioned socket such as/run/php/php8.3-fpm.sock; a containerized deployment may usephp-fpm:9000. A socket mismatch produces an upstream connection error. It cannot execute the script until Nginx points to the listener that actually exists.For a Unix socket, verify that the Nginx worker user can connect to the socket. The socket’s owner, group, and mode are controlled by PHP-FPM pool settings. For TCP, verify that the address is reachable from the Nginx host or container and that the pool is bound to that address.
-
Validate and reload
Run:
sudo nginx -t sudo nginx -s reloadOnly reload after the syntax check succeeds. Nginx keeps the previous working configuration when a test fails, so an edit that was never successfully loaded cannot change the response. A platform service command such as
systemctl reload nginxis equivalent when supported.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Test safely, then remove diagnostics
Create a temporary script in the document root:
<?php header('Content-Type: text/plain'); echo "PHP handler reachedn";Request it from a protected environment and remove it immediately. A full
phpinfo()page reveals paths, modules, and environment details; never leave one publicly accessible. -
Read both logs
Review the Nginx error log and the PHP-FPM log at the time of a single test request. Messages about a failed upstream connection indicate an endpoint or service problem. “Primary script unknown,” “No input file specified,” or a 404 from PHP-FPM points to a root, filename, chroot, or
try_filesproblem. Permission-denied messages usually identify the socket, directory traversal, or script-read permissions that must be corrected.
A complete, conservative server-block pattern
The following pattern serves a site from /var/www/site/public, rejects nonexistent PHP paths before forwarding them, and sends scripts to a Unix socket. Adapt the root, socket, index list, and non-PHP locations to your deployment:
server {
listen 80;
server_name example.test;
root /var/www/site/public;
index index.php index.html;
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/php8.3-fpm.sock;
}
location ~ /.ht {
deny all;
}
}
The location / rule first serves an existing file or directory. If neither exists, it internally redirects to /index.php while preserving the query string. The PHP rule then handles that internal URI. The separate denial rule prevents common per-directory configuration files from being served.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #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.
Understand each FastCGI directive
include fastcgi_params
This imports the standard request parameters supplied by the Nginx installation. They include values such as the request method, query string, content length, and URI. Distribution packages may provide a file with a slightly different name or contents, so inspect the included file when debugging.
fastcgi_pass
This is the hand-off to PHP-FPM. Nginx accepts either a Unix socket, for example unix:/run/php/php8.3-fpm.sock, or a TCP endpoint, for example 127.0.0.1:9000 or php-fpm:9000 in a container network. The value is not interchangeable: use the address shown by the active PHP-FPM pool and make sure Nginx can reach it.
fastcgi_param SCRIPT_FILENAME
PHP-FPM needs the filesystem path of the script, not just the URL. The common expression joins the active root and the FastCGI script name:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
For a request such as /index.php, $fastcgi_script_name is /index.php. If the root is /var/www/site/public, PHP-FPM receives /var/www/site/public/index.php. If the root differs between Nginx and PHP-FPM, the same expression still produces a path PHP-FPM cannot read; align the filesystem view or use the path mapping required by the deployment.
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 →try_files $fastcgi_script_name =404
This checks that the requested script exists before Nginx forwards it. A nonexistent URI receives a 404 instead of being passed to PHP-FPM, which reduces confusing upstream errors and prevents arbitrary path suffixes from being treated as scripts. Place the check inside the PHP location so it uses the location’s root and script name.
Unix socket or TCP: choose the listener that exists
| Endpoint | Example | What to verify |
|---|---|---|
| Unix-domain socket | unix:/run/php/php8.3-fpm.sock |
The socket path exists, PHP-FPM is listening there, and the Nginx worker has permission to connect. |
| TCP listener | 127.0.0.1:9000 |
PHP-FPM is bound to that address and port, and local firewall or service policy permits the connection. |
| Container service name | php-fpm:9000 |
Both containers share a network, DNS resolves the service name, and the PHP-FPM process listens on the container interface. |
A Unix socket is local to the filesystem namespace where PHP-FPM creates it. If Nginx and PHP-FPM run in separate containers, a host socket path generally is not shared unless a volume is mounted into both containers. In that arrangement, a TCP service name is normally the appropriate target. Conversely, a host installation may expose only a versioned Unix socket and no TCP listener.
Fix root and path mapping errors
Single-site document root
Keep one authoritative root in the server block when possible:
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.
root /srv/www/example/public;
With that root, /login.php maps to /srv/www/example/public/login.php. Avoid placing a second, different root inside the PHP location unless you deliberately need a separate mapping. A nested root changes $document_root and can make the same URL map to a different file.
Container or chroot mapping
Nginx and PHP-FPM may see different absolute paths. For example, Nginx could see /var/www/public/index.php while a PHP-FPM container mounts that directory as /app/public. In that case, concatenating Nginx’s $document_root produces a path that does not exist inside PHP-FPM. Mount the files at the same path in both services, or configure an explicit path mapping consistent with the PHP-FPM pool’s chroot and working directory. The logs from PHP-FPM reveal which path it attempted to open.
Do not duplicate the root
These two forms are not equivalent:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$document_root$fastcgi_script_name;
The second duplicates the root and is wrong for a normal installation. Likewise, hard-coding /var/www/site while the active server block uses /var/www/site/public points PHP-FPM at the wrong directory.
Front controllers and internal redirects
Framework applications often expose one public entry point, commonly index.php. A request for /products/42 may not correspond to a physical file. The try_files $uri $uri/ /index.php?$query_string; rule internally redirects that request to the front controller, where the PHP location executes it. This explains why the home page can work while a direct .php URL downloads: the front-controller URI may be handled by the PHP rule, while the direct URI is captured by a static or higher-priority location.
Do not remove the PHP location merely because the front controller works. Direct scripts, administrative tools, health checks, and internal redirects all still require a valid FastCGI handler. Conversely, do not forward every URI to PHP without an existence check unless the application deliberately needs that behavior; permissive forwarding can turn malformed paths into confusing PHP errors.
Recommended Free Tools
PATH_INFO URLs such as file.php/articles/1
When an application uses PATH_INFO, the script name and extra path must be separated. For /file.php/articles/1, PHP-FPM should receive /file.php as the script and /articles/1 as PATH_INFO. If $fastcgi_script_name includes the entire suffix, SCRIPT_FILENAME points to a nonexistent filename.
Use a location and parameter split that matches the FastCGI reference for your Nginx version and application. Test both the plain script URL and the PATH_INFO form after changing it. Keep try_files focused on the actual script portion so a valid script is not rejected merely because it has an informational path suffix.
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.
Why common quick fixes fail
- Adding a MIME type: MIME settings change the response type, not execution. Nginx still serves the PHP bytes unless a FastCGI hand-off occurs.
- Installing PHP CLI only: The command-line interpreter does not provide a network or socket listener for Nginx. PHP-FPM and an active pool are required.
- Copying a socket path from another server: Socket names commonly include the installed PHP version and distribution-specific directory. Confirm the path on this host.
- Editing an inactive file: Nginx may be loading a different server block or an included file. Use
nginx -Tto find the effective configuration. - Reloading without testing: A syntax error prevents the new configuration from loading, leaving the old behavior in place.
- Removing
try_filesto hide 404s: This can pass invalid paths to PHP-FPM and obscure the real root or URI problem. - Changing permissions broadly: Making the whole web tree world-writable is unsafe. Correct the socket group, directory traversal permissions, and script ownership specifically.
Interpret the symptom and log message
| Symptom | Likely cause | Next check |
|---|---|---|
| Browser downloads PHP source | Static location selected; PHP regex bypassed or absent. | Inspect location precedence and the active server block with nginx -T. |
| 502 Bad Gateway | Nginx cannot connect to PHP-FPM. | Check the service, socket or TCP listener, and socket permissions. |
| 404 from Nginx before PHP | try_files cannot find the script under the active root. |
Verify the URL, root, and file existence. |
| “Primary script unknown” | PHP-FPM received a path that does not exist in its filesystem view. | Compare SCRIPT_FILENAME, mounts, chroot settings, and the actual file path. |
| “No input file specified” | Wrong or duplicated root, incorrect script name, or a missing file. | Log the resolved path and correct the root-to-script mapping. |
| Only URLs with a suffix fail | PATH_INFO is being included in the script filename. | Split the script portion from PATH_INFO before forwarding. |
Secure the PHP-FPM boundary
PHP-FPM must not be reachable from an untrusted network. Prefer a Unix socket for a same-host deployment, or bind TCP to a private interface and restrict access with network policy when separate hosts or containers require it. Do not expose port 9000 directly to the internet.
Limit executable files where practical. Keep application secrets and configuration outside the public document root, deny hidden configuration files, and remove temporary diagnostic scripts. A correct FastCGI configuration should execute intended scripts without turning arbitrary uploaded files or path fragments into executable code.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Verification checklist
nginx -Tshows the intendedserver_name, root, and PHP location.- The test URI is matched by the PHP location rather than a
^~or competing regex location. - The root contains the requested script, and PHP-FPM can see that same path.
SCRIPT_FILENAMEis exactly the root plus the script name, with no duplicated prefix.try_files $fastcgi_script_name =404;rejects nonexistent scripts.fastcgi_passnames the active Unix socket or reachable TCP listener.- The Nginx worker can access the socket and traverse each parent directory.
sudo nginx -tsucceeds, followed by a reload.- A protected test script returns generated output, not source code, and is then deleted.
- Nginx and PHP-FPM logs are clean for the test request.
When to use a different configuration pattern
Direct script execution
Use the minimal PHP location when individual scripts are legitimate public endpoints. Keep the existence check enabled and restrict sensitive directories.
Front-controller routing
Use a root try_files rule that falls back to the framework’s entry script. This keeps pretty URLs working while still sending the entry script through FastCGI.
Containerized deployment
Use a service name and TCP port when Nginx and PHP-FPM are separate containers, and ensure both services mount application files at compatible paths. A host socket path that exists outside the container is not usable inside it.
Chrooted or multi-site PHP-FPM pools
Confirm the pool’s chroot, user, and group before choosing SCRIPT_FILENAME. Each pool may require a different filesystem path even when Nginx serves several sites from one host.
Final validation
After the change, request a harmless PHP endpoint twice: once by its direct .php URL and once through the application’s normal route. Confirm that the response is generated, query strings arrive intact, nonexistent scripts return 404, and logs show no upstream or path errors. Remove the test endpoint and retain the configuration only after both routing paths behave as intended.
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.

