When importing large databases using phpMyAdmin in CyberPanel, you may encounter upload size restrictions due to PHP's default configuration. This guide provides a ready-to-use bash script to massively increase the upload limits (upload_max_filesize and post_max_size) for all PHP (lsphp) versions used by CyberPanel, ensuring seamless database imports up to the size you set.
phpMyAdmin relies on PHP settings to determine the maximum allowed upload size. By default, this limit is often set very low (2MB or 8MB). Increasing these limits is essential if you plan to import large database dumps.
- Access to your server via SSH as root or with sudo privileges.
- CyberPanel installed (LiteSpeed stack with lsphp).
- Basic knowledge of Linux shell scripting.
Create a new file called upload_limit.sh and paste the following code inside:
#!/bin/bash
# Function to show usage
usage() {
echo "Usage: $0 <limit>"
echo "Example: $0 512M"
echo " $0 limit=1G"
exit 1
}
# Parse argument
if [ $# -lt 1 ]; then
usage
fi
if [[ "$1" =~ ^limit= ]]; then
NEW_LIMIT="${1#limit=}"
else
NEW_LIMIT="$1"
fi
# Validate the format: number followed by M or G
if [[ ! "$NEW_LIMIT" =~ ^[0-9]+[MG]$ ]]; then
echo "Error: Limit must be a number followed by 'M' or 'G' (e.g., 512M, 2G)"
usage
fi
echo "------------------------------------------------------"
echo " Setting upload limit in all CyberPanel PHP versions"
echo " New limit: $NEW_LIMIT"
echo "------------------------------------------------------"
CHANGED=0
# Buscar php.ini en lsphp81, lsphp82, lsphp83, lsphp84
for INI_FILE in /usr/local/lsws/lsphp*/etc/php/*/litespeed/php.ini; do
if [ -f "$INI_FILE" ]; then
echo ">> Modifying $INI_FILE"
# Backup if not done before
if [ ! -f "${INI_FILE}.bak" ]; then
cp "$INI_FILE" "${INI_FILE}.bak"
echo " Backup created: ${INI_FILE}.bak"
fi
# Change both settings (si existen, reemplaza; si no existen, añade al final)
grep -q '^upload_max_filesize' "$INI_FILE" \
&& sed -i "s/^upload_max_filesize\s*=.*/upload_max_filesize = $NEW_LIMIT/" "$INI_FILE" \
|| echo "upload_max_filesize = $NEW_LIMIT" >> "$INI_FILE"
grep -q '^post_max_size' "$INI_FILE" \
&& sed -i "s/^post_max_size\s*=.*/post_max_size = $NEW_LIMIT/" "$INI_FILE" \
|| echo "post_max_size = $NEW_LIMIT" >> "$INI_FILE"
CHANGED=1
echo " Limits updated in $INI_FILE"
fi
done
if [ "$CHANGED" = "1" ]; then
echo "Restarting lscpd service for CyberPanel..."
systemctl restart lscpd
echo "All done! The upload limits have been updated to $NEW_LIMIT."
else
echo "No php.ini files found or modified. Please check your installation."
fi
echo "------------------------------------------------------"
chmod +x upload_limit.shYou can set your desired limit in megabytes (M) or gigabytes (G). For example, to set the upload limit to 2GB:
./upload_limit.sh 2048MTip: The script will update both upload_max_filesize and post_max_size in every /usr/local/lsws/lsphp*/etc/php.ini file it finds. It also creates a backup of each original file as php.ini.bak the first time it is changed.
- Open phpMyAdmin from your CyberPanel dashboard.
- On the import page, you will now see your new limit displayed (for example, “Browse your computer: (Max: 2,048MiB)”).
- The script supports both M (megabytes) and G (gigabytes) for limits.
- If you need to revert changes, simply restore the .bak file for each php.ini (e.g., cp php.ini.bak php.ini).
- Always double-check that the change has taken effect by refreshing phpMyAdmin.