Apache shows PHP source or downloads .php files Nginx / Apache Origin: Edge & web server OSI layer 7 · Application Last updated 5 Nov 2026

Browser shows <?php code or downloads index.php — mod_php / PHP-FPM handler not configured in Apache

Apache serves PHP files as plain text because no PHP handler is active.

Exact message you may see Apache shows PHP source code instead of executingApache downloads php file instead of running<?php code displayed in browser ApacheApache PHP not working shows sourcephp file downloading Apache2
Seen on: Apache PHP Linux

Meaning

Enable PHP: sudo a2enmod php8.3 (mod_php with prefork MPM) or configure PHP-FPM with proxy_fcgi (a2enmod proxy_fcgi setenvif && a2enconf php8.3-fpm). Restart Apache. With the event MPM, mod_php won't work — use FPM. Also check AddHandler/SetHandler and that the file extension is mapped.

Common causes

  • PHP module/handler not enabled
  • Event MPM with mod_php
  • PHP-FPM conf not enabled
  • AddType missing
  • Vhost overriding handlers

⚡ Quick fix

  1. sudo a2enmod proxy_fcgi setenvif && sudo a2enconf php8.3-fpm && sudo systemctl restart apache2
  2. Or a2dismod mpm_event && a2enmod mpm_prefork php8.3
  3. Verify with php -v and a phpinfo() test

Detailed fix by platform

Linux

  1. apachectl -M | grep -E "php|proxy_fcgi|mpm"

How to diagnose

  1. Handler — Enabled?
  2. MPM — Compatible?
  3. FPM — Running?

🔧 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):

AH00015: Unable to open logs — Apache: AH00091: apache2: could not open error log file /var/log/apache2/error.log. AH00015: Unable to open logs (Permission denied) (Nginx / Apache)AH00015: Unable to op…AH00037: Symbolic link not allowed or link target not accessible — Apache: [core:error] AH00037: Symbolic link not allowed or link target not accessible: /var/www/html/current (Nginx / Apache)AH00037: Symbolic lin…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 (Nginx / Apache)AH00072: make_sock: c…AH00526: Syntax error on line of apache config — Apache: AH00526: Syntax error on line 12 of /etc/apache2/sites-enabled/site.conf: Invalid command 'Foo', perhaps misspelled or defined by a module not included in the server configuration (Nginx / Apache)AH00526: Syntax error…AH00558 — Apache: AH00558: apache2: Could not reliably determine the server's fully qualified domain name (Nginx / Apache)AH00558missing the MySQL extension — WordPress: Your PHP installation appears to be missing the MySQL extension which is required by WordPress (WordPress)missing the MySQL ext…PHP file downloads instead of running (Nginx) — Browser downloads index.php instead of rendering — Nginx has no fastcgi PHP location (Nginx / Apache)PHP file downloads in…Primary script unknown — FastCGI sent in stderr: "Primary script unknown" (PHP)Primary script unknownApache sh…

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.