Get started

How to fix PHP files downloading instead of running

After moving cPanel accounts to a LiteSpeed server, PHP files can download in the browser instead of running. Here is why, and the script that fixes it.

15 January 2026 · 4 min read

Overview

After moving cPanel accounts to a server running LiteSpeed Web Server, some sites may start downloading the index.php file instead of running it.

The usual cause is PHP handler lines left in .htaccess from the old server. They point to EasyApache PHP handlers (ea-php), which LiteSpeed doesn't use, instead of LiteSpeed's own handler (lsphp).

Why this happens

cPanel often writes PHP handler rules into .htaccess, such as:

AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml

These work on Apache with EasyApache, but LiteSpeed running LSPHP doesn't recognise them. LiteSpeed then doesn't pass the file to PHP at all, and sends .php files to the browser as plain downloads.

Step 1: Find the affected accounts

This script lists the accounts under /home2 whose files still contain the EasyApache handler. If your accounts live in /home, change the path in the script before running it.

Script: check_php_handler_issue.sh

#!/bin/bash
# This script checks all users in /home2 for .htaccess files
# that contain the old EasyApache PHP handler lines

echo "๐Ÿ” Scanning for .htaccess files with EA-PHP handlers in /home2..."

for user_home in /home2/*; do
    [ -d "$user_home" ] || continue
    user=$(basename "$user_home")

    if grep -Rqs "AddHandler application/x-httpd-ea-php" "$user_home"; then
        echo "โš ๏ธ  $user"
    fi
done

echo "โœ… Scan completed."

Usage

chmod +x check_php_handler_issue.sh
sh check_php_handler_issue.sh

It prints the username of each account that still has the old handler.

Step 2: Fix all affected accounts

If the scan finds more than a couple of accounts, run this script to remove the handler lines from every .htaccess file in one go:

Script: fix_all_php_handlers.sh

#!/bin/bash
# This script fixes the "ea-php handler" issue in .htaccess for all users in /home2

echo "๐Ÿ”ง Fixing .htaccess PHP handler issues for all users in /home2..."

for user_home in /home2/*; do
    [ -d "$user_home" ] || continue
    user=$(basename "$user_home")
    echo "๐Ÿงฉ Checking user: $user"
    
    find "$user_home" -type f -name ".htaccess" | while read -r file; do
        if grep -q "AddHandler application/x-httpd-ea-php" "$file"; then
            echo " ๐Ÿงน Fixing: $file"
            cp -f "$file" "$file.bak_$(date +%F_%T)"
            sed -i '/AddHandler application\/x-httpd-ea-php/d' "$file"
            sed -i '/<IfModule mime_module>/{N;/\n[[:space:]]*<\/IfModule>/d}' "$file"
        fi
    done
done

echo "โœ… All users processed. EA-PHP handlers removed safely."
echo "๐Ÿ—‚๏ธ Backups created with .bak_ suffix."

Usage

chmod +x fix_all_php_handlers.sh
sh fix_all_php_handlers.sh

What the script does

  • It goes through every account in /home2.
  • In each .htaccess that contains the EasyApache handler, it removes the AddHandler lines.
  • It saves a copy of each .htaccess with a .bak_ suffix before changing it.
  • It then removes the <IfModule mime_module> block that held the handler, but only once that block is empty. LiteSpeed Cache rules and other <IfModule> blocks are left as they are.

Step 3: Check that PHP runs

After running the fix, open one of the affected sites.
If it loads normally, the problem is fixed.

To test PHP directly:

1. Create a file info.php in public_html

<?php phpinfo(); ?>

2. Visit https://domain.com/info.php

If you see the PHP information page, the handler is working. Delete info.php afterwards, because it shows details about your server's configuration.

Before and after running the scripts

  • Back up your /home2 directory before running any batch script.
  • The scripts only change .htaccess files. No other website data is touched.
  • After the fix, go to WHM โ†’ MultiPHP Manager and check that each domain uses a valid PHP version (for example PHP 8.2) with LiteSpeed LSAPI.
  • On CloudLinux, check that the alt-php or lsphp packages for the versions you need are installed.

Quick reference

IssueCauseSolution
PHP files downloading instead of executing.htaccess using EasyApache handlerRemove AddHandler application/x-httpd-ea-php lines
public_html empty or missingIncomplete migrationCheck with ls -A /home2/USER/public_html and restore the account's files from its backup
LSCache or rewrite errorsOld handler blocksClean .htaccess using fix_all_php_handlers.sh

Tags:

apache mime types

bash script for cpanel

cpanel migration problems

cpanel php handler configuration

cpanel to cpanel migration issue

fix php file download issue

how to fix php files downloading in wordpress

htaccess php handler

linux server fix

litespeed php handler fix

litespeed web server

php configuration fix

php downloading instead of running

php execution issue

php files downloading cpanel

php files downloading in browser

php files downloading instead of executing

php handler issue cpanel

php mime type error

php not executing

php not executing after migration

server configuration error

web hosting troubleshooting

why are php files downloading instead of opening

wordpress php issue

Business Guide

How to Choose the Best Web Hosting for Your Business 2026

How to pick a hosting plan that fits your business, your budget and your plans for growth.

Read More โ†’

Technical Guide

How to Update PHP Settings for All Versions in cPanel & CloudLinux Using a Bash Script

Use one Bash script to apply the same php.ini settings to every EA-PHP and ALT-PHP version on a server.

Read More โ†’