PHP file downloads instead of running (Nginx) Nginx / Apache Origin: Edge & web server OSI layer 7 · Application Last updated 5 Nov 2026

Browser downloads index.php instead of rendering — Nginx has no fastcgi PHP location

Nginx serves .php files as static downloads because no location ~ \.php$ passes them to PHP-FPM.

Exact message you may see nginx downloads php file instead of executingPHP file is downloading instead of executing nginxnginx shows PHP source code instead of runningindex.php downloaded nginx php-fpm not configurednginx application/octet-stream PHP download
Seen on: Nginx PHP Linux

Meaning

Add a PHP location block with fastcgi_pass to the FPM socket/port, include fastcgi_params and SCRIPT_FILENAME, and install/start PHP-FPM. Also check the location block order and that try_files doesn't intercept .php.

Common causes

  • No PHP location block
  • PHP-FPM not installed/running
  • Wrong fastcgi_pass
  • Location regex not matching
  • Snippet include commented out

⚡ Quick fix

  1. Add location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.3-fpm.sock; }
  2. Install and start php8.3-fpm
  3. nginx -t and reload

Detailed fix by platform

Nginx

  1. location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/run/php/php8.3-fpm.sock; }

How to diagnose

  1. Location — PHP block present?
  2. FPM — Running?
  3. Socket — Correct?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Edge & web server. Errors that are often confused with or caused by this one (click to open):

1000 — Cloudflare Error 1000: DNS points to prohibited IP (Cloudflare)10001001 — Cloudflare Error 1001: DNS resolution error (Cloudflare)10011002 — Cloudflare Error 1002: DNS points to Prohibited IP / Restricted (Cloudflare)10021004 — Cloudflare Error 1004: Host Not Configured to Serve Web Traffic (Cloudflare)10041018 — Cloudflare Error 1018: Could not find host (Cloudflare)10181034 — Cloudflare Error 1034: Edge IP Restricted (Cloudflare)1034413 — HTTP 413 Content Too Large (Request Entity Too Large) (HTTP)413AH00558 — Apache: AH00558: apache2: Could not reliably determine the server's fully qualified domain name (Nginx / Apache)AH00558PHP file …

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.