When a .php URL makes the browser download the file, prompt to save it, or display the raw PHP source on the page, the server is treating PHP as a static file instead of running it through an interpreter. Apache no longer has a handler mapped for .php, so it serves the file as plain text or an octet-stream. This usually shows up right after a PHP version change, an EasyApache rebuild, a broken .htaccess, or a migration where the handler config did not come along. The fix is to restore the mapping between the .php extension and a PHP handler for that account.
What’s happening
Apache decides what to do with a file by its handler. For PHP to execute, the .php extension must be associated with a PHP handler — PHP-FPM, suPHP, CGI, or FastCGI — so Apache hands the file to the interpreter rather than returning its bytes. When that association is missing or broken, Apache falls back to serving the file as a static asset: depending on the MIME setup you get a download prompt, an application/octet-stream, or the source printed in the page.
On cPanel the mapping is managed by MultiPHP Manager and EasyApache 4, and it breaks in a few recognizable ways: the account was set to “inherit” or to a PHP version that is not installed, so no handler exists; an EasyApache 4 rebuild removed the PHP version or the handler module the account relied on; an .htaccess contains a bad AddHandler/AddType/SetHandler line (or one copied from another server) that overrides the working mapping; or a migration brought files but not the per-account PHP version setting, leaving the account with no valid handler on the new box. If every site on the server downloads PHP, the handler is missing server-wide; if only one account does, it is that account’s PHP version setting or .htaccess.
How to verify
Check which PHP version and handler the account is set to, and whether that version is installed.
# Which PHP version is mapped for this domain?
grep -i "<domain>" /etc/userdatadomains
# Which PHP versions and handlers does EasyApache have installed?
whmapi1 php_get_installed_versions
whmapi1 php_get_system_default_version
# Per-account version (MultiPHP Manager stores it here)
cat /var/cpanel/userdata/<cpaneluser>/<domain>.php_fpm.yaml 2>/dev/null
Look for a handler directive in .htaccess that could be overriding things, and confirm what Apache returns.
# AddHandler / AddType / SetHandler lines in the account's .htaccess
grep -rniE 'addhandler|addtype|sethandler|php' /home/<cpaneluser>/public_html/.htaccess
# What content-type does Apache send for a .php file?
curl -sI https://example.com/index.php | grep -i 'content-type'
# text/html -> executing; application/octet-stream or text/plain -> NOT executing
If it is server-wide, confirm the PHP handler module is actually loaded:
httpd -M 2>/dev/null | grep -iE 'php|proxy_fcgi|suexec'
The fix
- Set a valid PHP version in MultiPHP Manager — the most common fix. In WHM » MultiPHP Manager (or cPanel » Select PHP Version), set the domain to a specific installed PHP version rather than “inherit” or a missing one. Applying a real version rewrites the handler mapping and PHP starts executing again. Confirm the
Content-Typeistext/htmlafterward. - Remove a bad handler line from .htaccess —
grepfound anAddHandler/AddType/SetHandlerreferencing a handler or path that does not exist on this server (a frequent migration leftover). Delete the line and let cPanel’s managed handler take over, or replace it with the correct directive for the installed handler. Test by temporarily renaming.htaccess. - Reinstall the PHP version after an EasyApache rebuild — if a rebuild dropped the version the account used, reinstall it in WHM » EasyApache 4 (select the
ea-phpNNpackage), then re-apply the version in MultiPHP Manager. A rebuild that removes a PHP package leaves every account on that version with no handler. - Restore the system-wide handler module — if
httpd -Mshows no PHP/proxy_fcgimodule and all sites download PHP, the handler is missing server-wide. Rebuild with the PHP handler selected in EasyApache 4 so Apache can route.phpagain. This is the cause when the whole server is affected, not one account. - Fix a post-migration version mismatch — the account has no PHP version set on the new server. Assign the version the app expects in MultiPHP Manager and enable its extensions (see the site-broken-after-restore runbook). Migrated accounts frequently land with the PHP setting blank.
- Avoid hand-rolled AddHandler on modern cPanel — on PHP-FPM/suPHP setups, the right place to control PHP is MultiPHP Manager, not a manual
AddHandler application/x-httpd-phpin.htaccess. Hand-written handler lines that worked on an old DSO server commonly cause the download behaviour after a move; remove them and use the UI. - Clear caches and re-test — after fixing the handler, a cached response or OPcache state can briefly show the old behaviour. Reload and check the
Content-Typeheader directly withcurl -sI; that header, not the rendered page, tells you PHP is executing.
Once the account has a valid PHP version and no .htaccess is overriding the handler, load the .php URL and confirm curl -sI returns Content-Type: text/html with executed output, not a download or raw source — that header is the definitive proof PHP is running again. Stack Harbor handles cPanel PHP handler and MultiPHP triage under cPanel server administration — start a conversation.