mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-02 03:16:15 +01:00
Update PHP version handling and installation logic across scripts
- Adjusted PHP version priority in cyberpanel_upgrade.sh and install.py to include PHP 8.5 (beta) as the highest priority. - Enhanced package installation logic in cyberpanel.sh and installCyberPanel.py to install PHP dependencies more robustly, including error handling for missing packages. - Updated README.md to reflect the new recommended PHP versions and deprecated versions. - Improved error handling and dependency management in phpUtilities.py and upgrade.py for better installation reliability.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
**Web Hosting Control Panel powered by OpenLiteSpeed**
|
||||
Fast • Secure • Scalable — Simplify hosting management with style.
|
||||
|
||||
**Version**: 2.5.5 • **Updated**: September 23, 2025
|
||||
**Version**: 2.5.5 • **Updated**: September 24, 2025
|
||||
|
||||
[](https://github.com/usmannasir/cyberpanel)
|
||||
[](https://cyberpanel.net/KnowledgeBase/)
|
||||
@@ -84,8 +84,9 @@ Fast • Secure • Scalable — Simplify hosting management with style.
|
||||
|
||||
## PHP support (short)
|
||||
|
||||
* ✅ **Recommended**: PHP 8.5, 8.4, 8.3, 8.2, 8.1
|
||||
* ✅ **Recommended**: PHP 8.5 (beta), 8.4, 8.3, 8.2, 8.1
|
||||
* ⚠️ **Legacy**: PHP 8.0, PHP 7.4 (security-only)
|
||||
* ❌ **Deprecated**: PHP 7.1, 7.2, 7.3 (no longer installed)
|
||||
|
||||
Third-party repositories (Remi, Ondrej) may provide older or niche versions; verify compatibility before use.
|
||||
|
||||
|
||||
@@ -347,23 +347,16 @@ install_php_packages() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Try to install packages for each available PHP version
|
||||
packages_to_install=""
|
||||
# Try to install packages for each available PHP version individually
|
||||
for php_version in $available_php_versions; do
|
||||
# Check if package exists before adding to install list
|
||||
# Check if package exists before installing
|
||||
if yum search ${php_version}-${php_extension} 2>/dev/null | grep -q "${php_version}-${php_extension}"; then
|
||||
packages_to_install="${packages_to_install} ${php_version}-${php_extension}"
|
||||
install_package "${php_version}-${php_extension}" || log_warning "Failed to install ${php_version}-${php_extension}"
|
||||
fi
|
||||
if yum search ${php_version}-pecl-${php_extension} 2>/dev/null | grep -q "${php_version}-pecl-${php_extension}"; then
|
||||
packages_to_install="${packages_to_install} ${php_version}-pecl-${php_extension}"
|
||||
install_package "${php_version}-pecl-${php_extension}" || log_warning "Failed to install ${php_version}-pecl-${php_extension}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n "$packages_to_install" ]]; then
|
||||
install_package "$packages_to_install"
|
||||
else
|
||||
log_warning "No matching ${php_extension} packages found for available PHP versions"
|
||||
fi
|
||||
;;
|
||||
"CentOS8"|"CentOS9"|"CentOSStream8"|"CentOSStream9"|"RHEL8"|"RHEL9"|"AlmaLinux8"|"AlmaLinux9"|"AlmaLinux10"|"RockyLinux8"|"RockyLinux9"|"openEuler2003"|"openEuler2203"|"openEuler2403")
|
||||
# Find available PHP versions first
|
||||
@@ -373,23 +366,16 @@ install_php_packages() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Try to install packages for each available PHP version
|
||||
packages_to_install=""
|
||||
# Try to install packages for each available PHP version individually
|
||||
for php_version in $available_php_versions; do
|
||||
# Check if package exists before adding to install list
|
||||
# Check if package exists before installing
|
||||
if dnf search ${php_version}-${php_extension} 2>/dev/null | grep -q "${php_version}-${php_extension}"; then
|
||||
packages_to_install="${packages_to_install} ${php_version}-${php_extension}"
|
||||
install_package "${php_version}-${php_extension}" || log_warning "Failed to install ${php_version}-${php_extension}"
|
||||
fi
|
||||
if dnf search ${php_version}-pecl-${php_extension} 2>/dev/null | grep -q "${php_version}-pecl-${php_extension}"; then
|
||||
packages_to_install="${packages_to_install} ${php_version}-pecl-${php_extension}"
|
||||
install_package "${php_version}-pecl-${php_extension}" || log_warning "Failed to install ${php_version}-pecl-${php_extension}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n "$packages_to_install" ]]; then
|
||||
install_package "$packages_to_install"
|
||||
else
|
||||
log_warning "No matching ${php_extension} packages found for available PHP versions"
|
||||
fi
|
||||
;;
|
||||
"Ubuntu1804"|"Ubuntu2004"|"Ubuntu2010"|"Ubuntu2204"|"Ubuntu2404"|"Ubuntu24043"|"Debian11"|"Debian12"|"Debian13")
|
||||
# Find available PHP versions first
|
||||
@@ -2290,6 +2276,13 @@ fi
|
||||
Post_Install_Addon_Mecached_LSMCD() {
|
||||
install_dev_tools
|
||||
|
||||
# Install SASL development headers for LSMCD compilation
|
||||
if [[ "$Server_OS" =~ ^(CentOS|RHEL|AlmaLinux|RockyLinux|CloudLinux|openEuler) ]] ; then
|
||||
dnf install -y cyrus-sasl-devel cyrus-sasl-lib cyrus-sasl-gssapi cyrus-sasl-plain || yum install -y cyrus-sasl-devel cyrus-sasl-lib cyrus-sasl-gssapi cyrus-sasl-plain
|
||||
elif [[ "$Server_OS" = "Ubuntu" ]] ; then
|
||||
apt-get install -y libsasl2-dev libsasl2-modules
|
||||
fi
|
||||
|
||||
wget -O lsmcd-master.zip https://cyberpanel.sh/codeload.github.com/litespeedtech/lsmcd/zip/master
|
||||
unzip lsmcd-master.zip
|
||||
Current_Dir=$(pwd)
|
||||
@@ -2332,8 +2325,24 @@ Post_Install_Addon_Memcached() {
|
||||
Post_Install_Addon_Redis() {
|
||||
log_function_start "Post_Install_Addon_Redis"
|
||||
log_info "Installing Redis server and PHP extension"
|
||||
# Install PHP Redis extension
|
||||
install_php_packages "redis"
|
||||
|
||||
# Install PHP Redis extension for available PHP versions
|
||||
# Check which PHP versions are actually installed
|
||||
for php_version in $(ls /usr/local/lsws/lsphp* 2>/dev/null | grep -o 'lsphp[0-9]*' | sort -u); do
|
||||
if [[ "$Server_OS" =~ ^(CentOS|RHEL|AlmaLinux|RockyLinux|CloudLinux|openEuler) ]] ; then
|
||||
# Try to install Redis extension for this PHP version
|
||||
if dnf search ${php_version}-pecl-redis 2>/dev/null | grep -q "${php_version}-pecl-redis"; then
|
||||
dnf install -y ${php_version}-pecl-redis || yum install -y ${php_version}-pecl-redis
|
||||
elif dnf search ${php_version}-redis 2>/dev/null | grep -q "${php_version}-redis"; then
|
||||
dnf install -y ${php_version}-redis || yum install -y ${php_version}-redis
|
||||
fi
|
||||
elif [[ "$Server_OS" = "Ubuntu" ]] ; then
|
||||
# Ubuntu Redis extension installation
|
||||
if apt-cache search ${php_version}-redis 2>/dev/null | grep -q "${php_version}-redis"; then
|
||||
apt-get install -y ${php_version}-redis
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Install Redis server
|
||||
if [[ "$Server_OS" = "CentOS" ]]; then
|
||||
|
||||
@@ -1257,7 +1257,8 @@ if [[ ! -f /usr/local/lscp/fcgi-bin/lsphp ]] || [[ ! -s /usr/local/lscp/fcgi-bin
|
||||
PHP_RESTORED=0
|
||||
|
||||
# Try to find the latest lsphp version (check from newest to oldest)
|
||||
for PHP_VER in 83 82 81 80 74 73 72; do
|
||||
# Priority: 85 (beta), 84, 83, 82, 81, 80, 74
|
||||
for PHP_VER in 85 84 83 82 81 80 74; do
|
||||
if [[ -f /usr/local/lsws/lsphp${PHP_VER}/bin/lsphp ]]; then
|
||||
# Try to create symlink first (preferred)
|
||||
if ln -sf /usr/local/lsws/lsphp${PHP_VER}/bin/lsphp /usr/local/lscp/fcgi-bin/lsphp 2>/dev/null; then
|
||||
|
||||
@@ -1248,10 +1248,19 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
|
||||
|
||||
##
|
||||
|
||||
# Remove conflicting dovecot packages first
|
||||
try:
|
||||
if self.distro in [centos, cent8]:
|
||||
preFlightsChecks.call('yum remove -y dovecot dovecot-*', self.distro,
|
||||
'Remove conflicting dovecot packages',
|
||||
'Remove conflicting dovecot packages', 1, 0, os.EX_OSERR)
|
||||
except:
|
||||
pass # Continue if removal fails
|
||||
|
||||
if self.distro == centos:
|
||||
command = 'yum --enablerepo=gf-plus -y install dovecot23 dovecot23-mysql'
|
||||
command = 'yum --enablerepo=gf-plus -y install dovecot23 dovecot23-mysql --allowerasing'
|
||||
elif self.distro == cent8:
|
||||
command = 'dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y'
|
||||
command = 'dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y --allowerasing'
|
||||
elif self.distro == openeuler:
|
||||
command = 'dnf install dovecot -y'
|
||||
else:
|
||||
@@ -2693,8 +2702,8 @@ milter_default_action = accept
|
||||
logging.InstallLog.writeToFile("[setup_lsphp_symlink] Removed existing lsphp file/symlink")
|
||||
|
||||
# Try to find and use the best available PHP version
|
||||
# Priority: 83, 82, 81, 80, 74, 73, 72 (newest to oldest)
|
||||
php_versions = ['83', '82', '81', '80', '74', '73', '72']
|
||||
# Priority: 85 (beta), 84, 83, 82, 81, 80, 74 (newest to oldest)
|
||||
php_versions = ['85', '84', '83', '82', '81', '80', '74']
|
||||
lsphp_source = None
|
||||
|
||||
for php_ver in php_versions:
|
||||
|
||||
@@ -391,42 +391,93 @@ class InstallCyberPanel:
|
||||
|
||||
return self.reStartLiteSpeed()
|
||||
|
||||
def installPHPDependencies(self):
|
||||
"""Install required dependencies for PHP extensions"""
|
||||
try:
|
||||
InstallCyberPanel.stdOut("Installing PHP dependencies...", 1)
|
||||
|
||||
if self.distro == ubuntu:
|
||||
# Ubuntu dependencies
|
||||
deps = [
|
||||
'libmemcached-dev', 'libmemcached11',
|
||||
'libgd-dev', 'libgd3',
|
||||
'libc-client2007e-dev', 'libc-client2007e',
|
||||
'libonig-dev', 'libonig5',
|
||||
'libicu-dev', 'libicu70',
|
||||
'libaspell-dev', 'libaspell15',
|
||||
'libpspell-dev', 'libpspell1'
|
||||
]
|
||||
command = f'DEBIAN_FRONTEND=noninteractive apt-get -y install {" ".join(deps)}'
|
||||
os.system(command)
|
||||
else:
|
||||
# RHEL-based dependencies - enhanced list
|
||||
deps = [
|
||||
'libmemcached', 'libmemcached-devel', 'libmemcached-libs',
|
||||
'gd', 'gd-devel', 'libgd',
|
||||
'c-client', 'c-client-devel',
|
||||
'oniguruma', 'oniguruma-devel',
|
||||
'libicu', 'libicu-devel',
|
||||
'aspell', 'aspell-devel',
|
||||
'pspell', 'pspell-devel',
|
||||
'sendmail-milter', 'sendmail-milter-devel', # For libmilter
|
||||
'GeoIP', 'GeoIP-devel', # For geoip-devel
|
||||
'udns', 'udns-devel', # For udns-devel
|
||||
'sasl', 'cyrus-sasl-devel', # For SASL headers
|
||||
'libmilter', 'sendmail-milter-devel' # For libmilter.so.1.0
|
||||
]
|
||||
|
||||
for dep in deps:
|
||||
try:
|
||||
self.install_package(dep, '--skip-broken')
|
||||
except:
|
||||
pass # Continue if dependency installation fails
|
||||
|
||||
except Exception as e:
|
||||
InstallCyberPanel.stdOut(f"Warning: Some PHP dependencies may not be available: {str(e)}", 0)
|
||||
|
||||
def installAllPHPVersions(self):
|
||||
php_versions = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
|
||||
# Install PHP dependencies first
|
||||
self.installPHPDependencies()
|
||||
|
||||
# Updated PHP versions: Only 7.4+ and use 8.5 as beta
|
||||
# Priority: 85 (beta), 84, 83, 82, 81, 80, 74
|
||||
php_versions = ['74', '80', '81', '82', '83', '84', '85']
|
||||
|
||||
if self.distro == ubuntu:
|
||||
# Install base PHP 7.x packages
|
||||
# Install PHP 7.4 only (legacy support) with mbstring
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
|
||||
'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
|
||||
'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \
|
||||
'lsphp7?-sqlite3 lsphp7?-tidy'
|
||||
'lsphp74 lsphp74-common lsphp74-curl lsphp74-dev lsphp74-imap lsphp74-intl lsphp74-json ' \
|
||||
'lsphp74-ldap lsphp74-mysql lsphp74-opcache lsphp74-pspell lsphp74-recode ' \
|
||||
'lsphp74-sqlite3 lsphp74-tidy lsphp74-mbstring'
|
||||
os.system(command)
|
||||
|
||||
# Install PHP 8.x versions
|
||||
for version in php_versions[4:]: # 80, 81, 82, 83
|
||||
# Install PHP 8.x versions (8.0 to 8.5) with mbstring
|
||||
for version in php_versions[1:]: # 80, 81, 82, 83, 84, 85
|
||||
self.install_package(f'lsphp{version}*')
|
||||
# Ensure mbstring is installed for each version
|
||||
try:
|
||||
self.install_package(f'lsphp{version}-mbstring')
|
||||
except:
|
||||
pass
|
||||
|
||||
elif self.distro == centos:
|
||||
# First install the group
|
||||
command = 'yum -y groupinstall lsphp-all'
|
||||
install_utils.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
# Install PHP 7.4 only (legacy support)
|
||||
self.install_package('lsphp74*', '--skip-broken')
|
||||
|
||||
InstallCyberPanel.stdOut("LiteSpeed PHPs successfully installed!", 1)
|
||||
|
||||
# Install individual PHP versions
|
||||
for version in php_versions:
|
||||
# Install PHP 8.x versions
|
||||
for version in php_versions[1:]: # 80, 81, 82, 83, 84, 85
|
||||
self.install_package(f'lsphp{version}*', '--skip-broken')
|
||||
|
||||
elif self.distro == cent8:
|
||||
# Install PHP versions in batches with exclusions
|
||||
exclude_flags = "--exclude lsphp73-pecl-zip --exclude *imagick*"
|
||||
exclude_flags = "--exclude *imagick*"
|
||||
|
||||
# First batch: PHP 7.x and 8.0
|
||||
versions_batch1 = ' '.join([f'lsphp{v}*' for v in php_versions[:5]])
|
||||
# First batch: PHP 7.4 and 8.0-8.2
|
||||
versions_batch1 = 'lsphp74* lsphp80* lsphp81* lsphp82*'
|
||||
self.install_package(versions_batch1, f'{exclude_flags} --skip-broken')
|
||||
|
||||
# Second batch: PHP 8.1+
|
||||
versions_batch2 = ' '.join([f'lsphp{v}*' for v in php_versions[5:]])
|
||||
# Second batch: PHP 8.3-8.5 (including beta 8.5)
|
||||
versions_batch2 = 'lsphp83* lsphp84* lsphp85*'
|
||||
self.install_package(versions_batch2, f'{exclude_flags} --skip-broken')
|
||||
|
||||
elif self.distro == openeuler:
|
||||
|
||||
@@ -408,7 +408,7 @@ class phpUtilities:
|
||||
return result
|
||||
|
||||
else:
|
||||
command = f'grep -Po "php\d+" {vhFile} | head -n 1'
|
||||
command = f'grep -Po "php\\d+" {vhFile} | head -n 1'
|
||||
result = ProcessUtilities.outputExecutioner(command, None, True).rstrip('\n')
|
||||
result = f'/usr/local/lsws/ls{result}/bin/lsphp'
|
||||
result = result.rsplit("lsphp", 1)[0] + "php"
|
||||
@@ -454,8 +454,28 @@ class phpUtilities:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = f'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp{php}*'
|
||||
else:
|
||||
command = f'dnf install lsphp{php}* --exclude lsphp73-pecl-zip --exclude *imagick* -y --skip-broken'
|
||||
# Enhanced dependency handling for RHEL-based systems
|
||||
# First try to install required dependencies
|
||||
dependency_packages = [
|
||||
'libmemcached', 'libmemcached-devel', 'libmemcached-libs',
|
||||
'gd', 'gd-devel', 'libgd',
|
||||
'c-client', 'c-client-devel',
|
||||
'oniguruma', 'oniguruma-devel',
|
||||
'libicu', 'libicu-devel',
|
||||
'aspell', 'aspell-devel',
|
||||
'pspell', 'pspell-devel'
|
||||
]
|
||||
|
||||
# Install dependencies first
|
||||
for dep in dependency_packages:
|
||||
try:
|
||||
dep_command = f'dnf install -y {dep} --skip-broken'
|
||||
ProcessUtilities.executioner(dep_command, None, True)
|
||||
except:
|
||||
pass # Continue if dependency installation fails
|
||||
|
||||
# Install PHP with better error handling
|
||||
command = f'dnf install lsphp{php}* --exclude *imagick* -y --skip-broken --nobest'
|
||||
|
||||
ProcessUtilities.executioner(command, None, True)
|
||||
|
||||
|
||||
@@ -4112,15 +4112,15 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
||||
|
||||
for version in available_versions:
|
||||
try:
|
||||
if version in ['71', '72', '73', '74']:
|
||||
# PHP 7.x versions with specific extensions
|
||||
if version in ['74']:
|
||||
# PHP 7.4 only (legacy support) with specific extensions
|
||||
if Upgrade.installedOutput.find(f'lsphp{version}') == -1:
|
||||
extensions = ['json', 'xmlrpc', 'xml', 'tidy', 'soap', 'snmp', 'recode', 'pspell', 'process', 'pgsql', 'pear', 'pdo', 'opcache', 'odbc', 'mysqlnd', 'mcrypt', 'mbstring', 'ldap', 'intl', 'imap', 'gmp', 'gd', 'enchant', 'dba', 'common', 'bcmath']
|
||||
package_list = f"lsphp{version} " + " ".join([f"lsphp{version}-{ext}" for ext in extensions])
|
||||
command = f"yum install -y {package_list}"
|
||||
Upgrade.executioner(command, f'Install PHP {version}', 0)
|
||||
else:
|
||||
# PHP 8.x versions
|
||||
elif version in ['80', '81', '82', '83', '84', '85']:
|
||||
# PHP 8.x versions (including 8.5 beta)
|
||||
if Upgrade.installedOutput.find(f'lsphp{version}') == -1:
|
||||
command = f"yum install lsphp{version}* -y"
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
Reference in New Issue
Block a user