Enhance PHP support in installation and management scripts

- Added installation logic for PHP 8.6 in the install script, ensuring compatibility with various distributions.
- Updated PHP version lists in the PHPManager to include PHP 8.6 for system checks and fallbacks.
- Modified phpUtilities to recognize PHP 8.6 for CentOS and Ubuntu.
- Adjusted upgrade script to support PHP 8.6 for AlmaLinux 8+ compatibility.
- Revised symlink setup logic to prioritize PHP 8.6 alongside other versions.
This commit is contained in:
Master3395
2025-10-16 22:26:33 +02:00
parent 7ab1422e35
commit 293550c588
4 changed files with 44 additions and 27 deletions

View File

@@ -4503,6 +4503,17 @@ milter_default_action = accept
command = 'DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp85 lsphp85-*'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
# Install PHP 8.6
if not os.path.exists('/usr/local/lsws/lsphp86/bin/php'):
logging.InstallLog.writeToFile("[setupPHPSymlink] PHP 8.6 not found, ensuring it's installed...")
if self.distro == centos or self.distro == cent8 or self.distro == openeuler:
command = 'dnf install lsphp86 lsphp86-* -y --skip-broken --nobest'
else:
command = 'DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp86 lsphp86-*'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
# Remove existing PHP symlink if it exists
if os.path.exists('/usr/bin/php'):
@@ -4510,8 +4521,8 @@ 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)
php_versions = ['85', '84', '83', '82', '81', '80', '74']
# Priority: 86, 85, 84, 83, 82, 81, 80, 74 (newest to oldest, 7.4+ only for AlmaLinux 8+ compatibility)
php_versions = ['86', '85', '84', '83', '82', '81', '80', '74']
php_symlink_source = None
for php_ver in php_versions:
@@ -4561,8 +4572,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: 85 (beta), 84, 83, 82, 81, 80, 74 (newest to oldest)
php_versions = ['85', '84', '83', '82', '81', '80', '74']
# Priority: 86, 85, 84, 83, 82, 81, 80, 74 (newest to oldest)
php_versions = ['86', '85', '84', '83', '82', '81', '80', '74']
lsphp_source = None
for php_ver in php_versions:

View File

@@ -58,7 +58,7 @@ class PHPManager:
# Method 2: Check system-wide PHP installations
try:
# Check for system PHP versions
system_php_versions = ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
system_php_versions = ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
for version in system_php_versions:
formatted_version = f'PHP {version}'
if formatted_version not in finalPHPVersions:
@@ -117,7 +117,7 @@ class PHPManager:
# Method 4: Fallback to checking common PHP versions
if not finalPHPVersions:
fallback_versions = ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
fallback_versions = ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6']
for version in fallback_versions:
try:
phpString = PHPManager.getPHPString(version)
@@ -145,12 +145,12 @@ class PHPManager:
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
logging.writeToFile(f'Final PHP versions found: {finalPHPVersions}')
return finalPHPVersions if finalPHPVersions else ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
return finalPHPVersions if finalPHPVersions else ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6']
except BaseException as msg:
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
logging.writeToFile(f'Error while finding php versions on system: {str(msg)}')
return ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
return ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6']
@staticmethod
def findApachePHPVersions():
@@ -222,7 +222,7 @@ class PHPManager:
except BaseException as msg:
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
logging.writeToFile(f'Error while finding php versions on system: {str(msg)}')
return ['PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5']
return ['PHP 7.4', 'PHP 8.0', 'PHP 8.1', 'PHP 8.2', 'PHP 8.3', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6']
@staticmethod
def getPHPString(phpVersion):
@@ -338,7 +338,7 @@ class PHPManager:
return 'PHP 8.3' # Default recommendation
# Priority order for recommendations
recommended_order = ['PHP 8.3', 'PHP 8.2', 'PHP 8.4', 'PHP 8.5', 'PHP 8.1', 'PHP 8.0', 'PHP 7.4']
recommended_order = ['PHP 8.3', 'PHP 8.2', 'PHP 8.4', 'PHP 8.5', 'PHP 8.6', 'PHP 8.1', 'PHP 8.0', 'PHP 7.4']
for recommended in recommended_order:
if recommended in all_versions:

View File

@@ -373,6 +373,12 @@ class phpUtilities:
ubuntuPHP = 'php8.5'
phpPath = ApacheVhost.DecidePHPPath('86', virtualHostName)
if os.path.exists(phpPath):
centOSPHP = 'php86'
ubuntuPHP = 'php8.6'
######

View File

@@ -3630,19 +3630,16 @@ echo $oConfig->Save() ? 'Done' : 'Error';
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']
# AlmaLinux 9+ and 8+ only support PHP 7.4+
php_versions = ['74', '80', '81', '82', '83', '84', '85', '86']
else:
php_versions = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
php_versions = ['74', '80', '81', '82', '83', '84', '85', '86']
except:
php_versions = ['71', '72', '73', '74', '80', '81', '82', '83', '84', '85']
php_versions = ['74', '80', '81', '82', '83', '84', '85', '86']
else:
# Check other OS versions
# Check other OS versions - all modern systems support PHP 7.4+
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']
php_versions = ['74', '80', '81', '82', '83', '84', '85', '86']
# Check availability of each version
available_versions = []
@@ -4119,8 +4116,8 @@ echo $oConfig->Save() ? 'Done' : 'Error';
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)
elif version in ['80', '81', '82', '83', '84', '85']:
# PHP 8.x versions (including 8.5 beta)
elif version in ['80', '81', '82', '83', '84', '85', '86']:
# PHP 8.x versions (including 8.5 and 8.6)
if Upgrade.installedOutput.find(f'lsphp{version}') == -1:
command = f"yum install lsphp{version}* -y"
subprocess.call(command, shell=True)
@@ -4155,6 +4152,9 @@ echo $oConfig->Save() ? 'Done' : 'Error';
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp85*'
os.system(command)
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp86*'
os.system(command)
CentOSPath = '/etc/redhat-release'
openEulerPath = '/etc/openEuler-release'
@@ -4726,8 +4726,8 @@ slowlog = /var/log/php{version}-fpm-slow.log
This ensures that ImunifyAV/Imunify360 installation will work properly.
"""
try:
# Define all possible PHP versions
php_versions = ['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']
# Define all possible PHP versions (7.4+ for AlmaLinux 8+ compatibility)
php_versions = ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
restarted_count = 0
total_count = 0
@@ -4774,8 +4774,8 @@ slowlog = /var/log/php{version}-fpm-slow.log
def setupPHPSymlink():
try:
# Try to find available PHP version (prioritize modern stable versions)
# Priority: 8.3 (recommended), 8.2, 8.4, 8.5, 8.1, 8.0, then older versions
php_versions = ['83', '82', '84', '85', '81', '80', '74', '73', '72', '71']
# Priority: 8.3 (recommended), 8.2, 8.6, 8.5, 8.4, 8.1, 8.0, 7.4 (AlmaLinux 8+ compatible only)
php_versions = ['83', '82', '86', '85', '84', '81', '80', '74']
selected_php = None
for version in php_versions:
@@ -4995,8 +4995,8 @@ slowlog = /var/log/php{version}-fpm-slow.log
except:
pass
# Try to find available PHP binary in order of preference (modern stable first)
php_versions = ['83', '82', '84', '85', '81', '80', '74', '73', '72', '71']
# Try to find available PHP binary in order of preference (modern stable first, AlmaLinux 8+ compatible)
php_versions = ['83', '82', '86', '85', '84', '81', '80', '74']
php_binary_found = False
for version in php_versions: