mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-06 12:06:24 +02:00
fix(php): OS-specific lsphp install matrix shared install↔upgrade
Add install_utils.get_lsphp_install_suffixes() (Alma 9/10+, EL9+, Ubuntu 24.04+, Debian 13+ use 74–85; older OS keep 71–85). installCyberPanel.installAllPHPVersions uses the matrix and installs every listed lsphp on Ubuntu (fixes 74 skipped by slice). upgrade.get_available_php_versions loads the same helper from install/. Extend PHP-FPM restart loops to 8.4/8.5 and CloudLinux list to 85. Clarify /usr/bin/php symlink priority comments in install.py.
This commit is contained in:
@@ -5831,7 +5831,7 @@ milter_default_action = accept
|
||||
|
||||
# Create symlink to the best available PHP version
|
||||
# Try to find and use the best available PHP version
|
||||
# Priority: 85 (beta), 84, 83, 82, 81, 80, 74 (newest to oldest)
|
||||
# Priority: 85, 84, 83, 82, 81, 80, 74 (newest to oldest)
|
||||
php_versions = ['85', '84', '83', '82', '81', '80', '74']
|
||||
php_symlink_source = None
|
||||
|
||||
@@ -5882,7 +5882,7 @@ 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: 85 (beta), 84, 83, 82, 81, 80, 74 (newest to oldest)
|
||||
# Priority: 85, 84, 83, 82, 81, 80, 74 (newest to oldest)
|
||||
php_versions = ['85', '84', '83', '82', '81', '80', '74']
|
||||
lsphp_source = None
|
||||
|
||||
|
||||
@@ -755,18 +755,18 @@ module cyberpanel_ols {
|
||||
return self.reStartLiteSpeed()
|
||||
|
||||
def installAllPHPVersions(self):
|
||||
php_versions = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
|
||||
|
||||
# OS-aligned matrix (same base list as upgrade.get_available_php_versions pre-filter)
|
||||
php_versions = install_utils.get_lsphp_install_suffixes()
|
||||
|
||||
if self.distro == ubuntu:
|
||||
# Install base PHP 7.x packages
|
||||
# Install base PHP 7.x packages (wildcard) plus explicit matrix suffixes
|
||||
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'
|
||||
os.system(command)
|
||||
|
||||
# Install PHP 8.x versions
|
||||
for version in php_versions[4:]: # 80, 81, 82, 83
|
||||
|
||||
for version in php_versions:
|
||||
self.install_package(f'lsphp{version}*')
|
||||
|
||||
elif self.distro == centos:
|
||||
|
||||
@@ -289,6 +289,88 @@ openeuler = 3
|
||||
debian12 = 4
|
||||
|
||||
|
||||
def get_lsphp_install_suffixes():
|
||||
"""
|
||||
LiteSpeed lsphp* two-digit version suffixes to install for this OS (pre-repo check).
|
||||
Mirrors the base list in plogical/upgrade.py get_available_php_versions() before
|
||||
check_package_availability filtering.
|
||||
|
||||
Returns:
|
||||
list[str]: e.g. ['74','80',...,'85'] on AlmaLinux 9+/10+ and modern EL9/Ubuntu24+/Debian13+,
|
||||
or ['71',...,'85'] on older platforms where 7.1–7.3 packages exist.
|
||||
"""
|
||||
long_list = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
|
||||
short_list = ['74', '80', '81', '82', '83', '84', '85']
|
||||
|
||||
# AlmaLinux: explicit release file (matches upgrade.get_available_php_versions)
|
||||
if exists('/etc/almalinux-release'):
|
||||
try:
|
||||
with open('/etc/almalinux-release', 'r') as f:
|
||||
content = f.read().lower()
|
||||
if 'release 9' in content or 'release 10' in content:
|
||||
return list(short_list)
|
||||
except (OSError, IOError, UnicodeError):
|
||||
pass
|
||||
return list(long_list)
|
||||
|
||||
# Other RHEL family (Rocky/RHEL/CentOS Stream) without almalinux-release: EL9+ uses short list
|
||||
if exists('/etc/redhat-release'):
|
||||
try:
|
||||
with open('/etc/redhat-release', 'r') as f:
|
||||
data = f.read().lower()
|
||||
if (
|
||||
'release 9' in data
|
||||
or 'release 10' in data
|
||||
or 'stream 9' in data
|
||||
or 'stream 10' in data
|
||||
):
|
||||
return list(short_list)
|
||||
except (OSError, IOError, UnicodeError):
|
||||
pass
|
||||
|
||||
# Ubuntu 24.04+ (upgrade: Ubuntu24 branch)
|
||||
if exists('/etc/lsb-release'):
|
||||
try:
|
||||
with open('/etc/lsb-release', 'r') as f:
|
||||
lsb = f.read()
|
||||
if 'DISTRIB_ID=Ubuntu' in lsb:
|
||||
for line in lsb.splitlines():
|
||||
if line.startswith('DISTRIB_RELEASE='):
|
||||
rel = line.split('=', 1)[1].strip().strip('"').strip("'")
|
||||
try:
|
||||
parts = rel.split('.')
|
||||
major = int(parts[0])
|
||||
minor = int(parts[1]) if len(parts) > 1 else 0
|
||||
if major > 24 or (major == 24 and minor >= 4):
|
||||
return list(short_list)
|
||||
except (ValueError, IndexError):
|
||||
pass
|
||||
break
|
||||
except (OSError, IOError, UnicodeError):
|
||||
pass
|
||||
|
||||
# Debian 13+ (trixie+): upgrade uses Debian13 for short list
|
||||
if exists('/etc/os-release'):
|
||||
try:
|
||||
with open('/etc/os-release', 'r') as f:
|
||||
osr = f.read()
|
||||
osr_l = osr.lower().replace(' ', '')
|
||||
if 'id=debian' in osr_l:
|
||||
for line in osr.splitlines():
|
||||
if line.upper().startswith('VERSION_ID='):
|
||||
vid = line.split('=', 1)[1].strip().strip('"').strip("'")
|
||||
try:
|
||||
if int(vid.split('.')[0]) >= 13:
|
||||
return list(short_list)
|
||||
except (ValueError, IndexError):
|
||||
pass
|
||||
break
|
||||
except (OSError, IOError, UnicodeError):
|
||||
pass
|
||||
|
||||
return list(long_list)
|
||||
|
||||
|
||||
def get_distro():
|
||||
"""
|
||||
Detect Linux distribution
|
||||
|
||||
@@ -5368,27 +5368,33 @@ echo $oConfig->Save() ? 'Done' : 'Error';
|
||||
@staticmethod
|
||||
def get_available_php_versions():
|
||||
"""Get list of available PHP versions based on OS"""
|
||||
# Check for AlmaLinux 9+ first
|
||||
if os.path.exists('/etc/almalinux-release'):
|
||||
try:
|
||||
php_versions = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
|
||||
try:
|
||||
import importlib
|
||||
import sys
|
||||
_here = os.path.dirname(os.path.abspath(__file__))
|
||||
for _root in (
|
||||
os.path.join(os.path.dirname(_here), 'install'),
|
||||
'/usr/local/CyberCP/install',
|
||||
'/usr/local/CyberPanel/install',
|
||||
):
|
||||
if os.path.isfile(os.path.join(_root, 'install_utils.py')) and _root not in sys.path:
|
||||
sys.path.insert(0, _root)
|
||||
iu = importlib.import_module('install_utils')
|
||||
if hasattr(iu, 'get_lsphp_install_suffixes'):
|
||||
php_versions = iu.get_lsphp_install_suffixes()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.path.exists('/etc/almalinux-release'):
|
||||
with open('/etc/almalinux-release', 'r') as f:
|
||||
content = f.read()
|
||||
if 'release 9' in content or 'release 10' in content:
|
||||
Upgrade.stdOut("AlmaLinux 9+ detected - checking available PHP versions", 1)
|
||||
# AlmaLinux 9+ doesn't have PHP 7.1, 7.2, 7.3
|
||||
php_versions = ['74', '80', '81', '82', '83', '84', '85']
|
||||
else:
|
||||
php_versions = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
|
||||
except:
|
||||
php_versions = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
|
||||
else:
|
||||
# Check other OS versions
|
||||
os_info = Upgrade.findOperatingSytem()
|
||||
if os_info in [Ubuntu24, CENTOS8, Debian13]:
|
||||
php_versions = ['74', '80', '81', '82', '83', '84', '85']
|
||||
else:
|
||||
php_versions = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
|
||||
|
||||
_c = f.read().lower()
|
||||
if 'release 9' in _c or 'release 10' in _c:
|
||||
Upgrade.stdOut("AlmaLinux 9+ detected - checking available PHP versions", 1)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Check availability of each version
|
||||
available_versions = []
|
||||
for version in php_versions:
|
||||
@@ -7278,7 +7284,7 @@ extprocessor proxyApacheBackendSSL {
|
||||
Upgrade.executioner(command, f'Restart {apache_service}', 1)
|
||||
|
||||
# 5. Fix PHP-FPM socket permissions and restart services
|
||||
for version in ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']:
|
||||
for version in ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']:
|
||||
if Upgrade.FindOperatingSytem() in [CENTOS7, CENTOS8, openEuler20, openEuler22]:
|
||||
php_service = f'php{version.replace(".", "")}-php-fpm'
|
||||
socket_dir = '/var/run/php-fpm'
|
||||
@@ -7960,11 +7966,11 @@ RewriteRule ^(.*)$ https://proxyApacheBackendSSL/$1 [P,L]
|
||||
|
||||
# Restart PHP-FPM services
|
||||
if osType in [CENTOS7, CENTOS8, CloudLinux7, CloudLinux8]:
|
||||
for version in ['54', '55', '56', '70', '71', '72', '73', '74', '80', '81', '82', '83', '84']:
|
||||
for version in ['54', '55', '56', '70', '71', '72', '73', '74', '80', '81', '82', '83', '84', '85']:
|
||||
command = f'systemctl restart php{version}-php-fpm'
|
||||
Upgrade.executioner(command, command, 0, True)
|
||||
else:
|
||||
for version in ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']:
|
||||
for version in ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']:
|
||||
command = f'systemctl restart php{version}-fpm'
|
||||
Upgrade.executioner(command, command, 0, True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user