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

**Code:** `Apache shows PHP source or downloads .php files` · **Category:** Nginx / Apache · **Seen on:** Apache, PHP, Linux

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/nginx-apache/apache-php-source-shown-or-downloaded)
