mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-02-28 09:20:43 +01:00
feature: support upto php 8.4 on apache manager
This commit is contained in:
@@ -15,6 +15,7 @@ class ApacheController:
|
||||
|
||||
serverRootPath = '/etc/httpd'
|
||||
configBasePath = '/etc/httpd/conf.d/'
|
||||
phpBasepath = '/etc/opt/remi'
|
||||
php54Path = '/opt/remi/php54/root/etc/php-fpm.d/'
|
||||
php55Path = '/opt/remi/php55/root/etc/php-fpm.d/'
|
||||
php56Path = '/etc/opt/remi/php56/php-fpm.d/'
|
||||
@@ -37,6 +38,8 @@ class ApacheController:
|
||||
serverRootPath = '/etc/apache2'
|
||||
configBasePath = '/etc/apache2/sites-enabled/'
|
||||
|
||||
phpBasepath = '/etc/php'
|
||||
|
||||
php54Path = '/etc/php/5.4/fpm/pool.d/'
|
||||
php55Path = '/etc/php/5.5/fpm/pool.d/'
|
||||
php56Path = '/etc/php/5.6/fpm/pool.d/'
|
||||
|
||||
@@ -143,6 +143,12 @@ class ApacheVhost:
|
||||
if os.path.exists(ApacheVhost.php83Path + virtualHostName):
|
||||
return ApacheVhost.php83Path + virtualHostName
|
||||
|
||||
if os.path.exists(ApacheVhost.php84Path + virtualHostName):
|
||||
return ApacheVhost.php84Path + virtualHostName
|
||||
|
||||
if os.path.exists(ApacheVhost.php85Path + virtualHostName):
|
||||
return ApacheVhost.php85Path + virtualHostName
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -31,12 +31,72 @@ class PHPManager:
|
||||
lsphp_lines = [line for line in result.split('\n') if 'lsphp' in line]
|
||||
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
logging.writeToFile(f'Found PHP lines in findPHPVersions: {lsphp_lines}')
|
||||
|
||||
|
||||
# Extract the version from the lines and format it as 'PHP x.y'
|
||||
php_versions = ['PHP ' + line.split()[8][5] + '.' + line.split()[8][6:] for line in lsphp_lines]
|
||||
|
||||
finalPHPVersions = []
|
||||
for php in php_versions:
|
||||
phpString = PHPManager.getPHPString(php)
|
||||
|
||||
if os.path.exists("/usr/local/lsws/lsphp" + str(phpString) + "/bin/lsphp"):
|
||||
finalPHPVersions.append(php)
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
logging.writeToFile(f'Found PHP versions in findPHPVersions: {php_versions}')
|
||||
logging.writeToFile(f'Found PHP versions in findPHPVersions: {finalPHPVersions}')
|
||||
|
||||
# Now php_versions contains the formatted PHP versions
|
||||
return finalPHPVersions
|
||||
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']
|
||||
|
||||
@staticmethod
|
||||
def findApachePHPVersions():
|
||||
# distro = ProcessUtilities.decideDistro()
|
||||
# if distro == ProcessUtilities.centos:
|
||||
# return ['PHP 5.3', 'PHP 5.4', 'PHP 5.5', 'PHP 5.6', 'PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
|
||||
# elif distro == ProcessUtilities.cent8:
|
||||
# return ['PHP 7.1','PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
|
||||
# elif distro == ProcessUtilities.ubuntu20:
|
||||
# return ['PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
|
||||
# else:
|
||||
# return ['PHP 7.0', 'PHP 7.1', 'PHP 7.2', 'PHP 7.3', 'PHP 7.4', 'PHP 8.0', 'PHP 8.1']
|
||||
|
||||
try:
|
||||
|
||||
# Run the shell command and capture the output
|
||||
from ApachController.ApacheController import ApacheController as ApachController
|
||||
result = ProcessUtilities.outputExecutioner(f'ls -la {ApachController.phpBasepath}')
|
||||
|
||||
# Get the lines containing 'lsphp' in the output
|
||||
lsphp_lines = [line for line in result.split('\n') if 'php' in line]
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
logging.writeToFile(f'Found PHP lines in findApachePHPVersions: {lsphp_lines}')
|
||||
|
||||
# Extract the version from the lines and format it as 'PHP x.y'
|
||||
# Extract and format PHP versions
|
||||
php_versions = []
|
||||
for entry in lsphp_lines:
|
||||
# Find substring starting with 'php' and extract the version part
|
||||
version = entry.split('php')[1]
|
||||
# Format version as PHP X.Y
|
||||
formatted_version = f"PHP {version[0]}.{version[1]}"
|
||||
php_versions.append(formatted_version)
|
||||
|
||||
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
logging.writeToFile(f'Found PHP versions in findApachePHPVersions: {php_versions}')
|
||||
|
||||
# Now php_versions contains the formatted PHP versions
|
||||
return php_versions
|
||||
|
||||
@@ -1269,11 +1269,18 @@ def installExtensions(request):
|
||||
except:
|
||||
pass
|
||||
|
||||
# apache = ApacheController.checkIfApacheInstalled()
|
||||
apache = 1
|
||||
|
||||
apache = ApacheController.checkIfApacheInstalled()
|
||||
|
||||
if apache:
|
||||
if request.GET.get('apache', None) == None:
|
||||
phps = PHPManager.findPHPVersions()
|
||||
else:
|
||||
phps = PHPManager.findApachePHPVersions()
|
||||
else:
|
||||
phps = PHPManager.findPHPVersions()
|
||||
|
||||
proc = httpProc(request, 'managePHP/installExtensions.html',
|
||||
{'phps': PHPManager.findPHPVersions(), 'apache': apache}, 'admin')
|
||||
{'phps': phps, 'apache': apache}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
except KeyError:
|
||||
@@ -1674,10 +1681,18 @@ def getRequestStatusApache(request):
|
||||
|
||||
def editPHPConfigs(request):
|
||||
try:
|
||||
#apache = ApacheController.checkIfApacheInstalled()
|
||||
apache = 1
|
||||
apache = ApacheController.checkIfApacheInstalled()
|
||||
|
||||
if apache:
|
||||
if request.GET.get('apache', None) == None:
|
||||
phps = PHPManager.findPHPVersions()
|
||||
else:
|
||||
phps = PHPManager.findApachePHPVersions()
|
||||
else:
|
||||
phps = PHPManager.findPHPVersions()
|
||||
|
||||
proc = httpProc(request, 'managePHP/editPHPConfig.html',
|
||||
{'phps': PHPManager.findPHPVersions(), 'apache': apache}, 'admin')
|
||||
{'phps': phps, 'apache': apache}, 'admin')
|
||||
return proc.render()
|
||||
|
||||
except KeyError:
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
<div class="form-group mb-3">
|
||||
<label for="example-select">PHP</label>
|
||||
<select ng-model="phpSelection" class="form-control" id="example-select">
|
||||
{% for php in phps %}
|
||||
{% for php in apachePHPs %}
|
||||
<option>{{ php }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
@@ -6677,6 +6677,7 @@ StrictHostKeyChecking no
|
||||
return ACLManager.loadError()
|
||||
|
||||
phps = PHPManager.findPHPVersions()
|
||||
apachePHPs = PHPManager.findApachePHPVersions()
|
||||
|
||||
if ACLManager.CheckForPremFeature('all'):
|
||||
apachemanager = 1
|
||||
@@ -6684,7 +6685,7 @@ StrictHostKeyChecking no
|
||||
apachemanager = 0
|
||||
|
||||
proc = httpProc(request, 'websiteFunctions/ApacheManager.html',
|
||||
{'domainName': self.domain, 'phps': phps, 'apachemanager': apachemanager})
|
||||
{'domainName': self.domain, 'phps': phps, 'apachemanager': apachemanager, 'apachePHPs': apachePHPs})
|
||||
return proc.render()
|
||||
|
||||
def saveApacheConfigsToFile(self, userID=None, data=None):
|
||||
|
||||
Reference in New Issue
Block a user