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
.htaccessthat contains the EasyApache handler, it removes theAddHandlerlines. - It saves a copy of each
.htaccesswith 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
/home2directory before running any batch script. - The scripts only change
.htaccessfiles. 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
| Issue | Cause | Solution |
|---|---|---|
| PHP files downloading instead of executing | .htaccess using EasyApache handler | Remove AddHandler application/x-httpd-ea-php lines |
| public_html empty or missing | Incomplete migration | Check with ls -A /home2/USER/public_html and restore the account's files from its backup |
| LSCache or rewrite errors | Old handler blocks | Clean .htaccess using fix_all_php_handlers.sh |
Tags:
Related articles
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 โ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 โ