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.
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 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
- Add
location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.3-fpm.sock; } - Install and start
php8.3-fpm nginx -tand reload
Detailed fix by platform
Nginx
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
- Location — PHP block present?
- FPM — Running?
- 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:
Similar errors
Most viewed in Nginx / Apache
- upstream timed out Nginx: upstream timed out (110: Connection timed out) while reading response header from upstream
- AH00072: make_sock: could not bind to address 0.0.0.0:80 Apache: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 / AH00015: Unable to open logs
- AH00898: Error reading from remote server (502 Proxy Error) Apache: [proxy_http:error] AH01102: error reading status line from remote server 127.0.0.1:3000 / AH00898: Error reading from remote server returned by /api
Other ways to find it
Where this error sits
Origin: Edge & web server. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 5 Nov 2026