mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-11 15:56:11 +01:00
reuseable code for apache manager
This commit is contained in:
@@ -113,15 +113,15 @@ LoadModule mpm_event_module modules/mod_mpm_event.so
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
|
||||
command = "yum -y install centos-release-scl yum-utils"
|
||||
if ProcessUtilities.executioner(command) == 0:
|
||||
return "Failed to centos-release-scl and yum-utils"
|
||||
# command = "yum -y install centos-release-scl yum-utils"
|
||||
# if ProcessUtilities.executioner(command) == 0:
|
||||
# return "Failed to centos-release-scl and yum-utils"
|
||||
#
|
||||
# command = "yum-config-manager --enable rhel-server-rhscl-7-rpms"
|
||||
# if ProcessUtilities.executioner(command) == 0:
|
||||
# return "Failed to --enable rhel-server-rhscl-7-rpms"
|
||||
|
||||
command = "yum-config-manager --enable rhel-server-rhscl-7-rpms"
|
||||
if ProcessUtilities.executioner(command) == 0:
|
||||
return "Failed to --enable rhel-server-rhscl-7-rpms"
|
||||
|
||||
sslPath = "/etc/apache2/conf.d/ssl.conf"
|
||||
sslPath = "/etc/httpd/conf.d/ssl.conf"
|
||||
|
||||
if os.path.exists(sslPath):
|
||||
os.remove(sslPath)
|
||||
@@ -155,8 +155,6 @@ LoadModule mpm_event_module modules/mod_mpm_event.so
|
||||
|
||||
else:
|
||||
|
||||
|
||||
sslPath = "/etc/httpd/conf.d/ssl.conf"
|
||||
confPath = ApacheVhost.serverRootPath + "/apache2.conf"
|
||||
|
||||
portsPath = '/etc/apache2/ports.conf'
|
||||
|
||||
@@ -554,10 +554,7 @@ class ApacheVhost:
|
||||
|
||||
confFile.write(currentConf)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php{php}-php-fpm'
|
||||
else:
|
||||
phpService = f"{phpVersion.replace(' ', '').lower()}-fpm"
|
||||
phpService = ApacheVhost.DecideFPMServiceName(phpVersion)
|
||||
|
||||
command = f"systemctl stop {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
@@ -572,3 +569,36 @@ class ApacheVhost:
|
||||
except BaseException as msg:
|
||||
logging.writeToFile(str(msg))
|
||||
return 1
|
||||
|
||||
|
||||
@staticmethod
|
||||
def DecidePHPPathforManager(apache, phpVers):
|
||||
if apache == None:
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
final = phpVers[4]
|
||||
|
||||
completeName = str(initial) + '.' + str(final)
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
|
||||
else:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
path = f'/etc/opt/remi/{phpVers}/php.ini'
|
||||
else:
|
||||
path = f'/etc/php/{phpVers.split(" ")[1]}/fpm/php.ini'
|
||||
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(f'PHP Path {path}')
|
||||
|
||||
return path
|
||||
|
||||
@staticmethod
|
||||
def DecideFPMServiceName(phpVersion):
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
return f'php{php}-php-fpm'
|
||||
else:
|
||||
return f"{phpVersion.replace(' ', '').lower()}-fpm"
|
||||
@@ -1698,20 +1698,8 @@ def getCurrentPHPConfig(request):
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(f"apache value {request.GET.get('apache', None)}")
|
||||
|
||||
if request.GET.get('apache', None) == None:
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
final = phpVers[4]
|
||||
|
||||
completeName = str(initial) + '.' + str(final)
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
|
||||
else:
|
||||
path = f'/etc/php/{phpVers.split(" ")[1]}/fpm/php.ini'
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(f'PHP Path {path}')
|
||||
from ApachController.ApacheVhosts import ApacheVhost
|
||||
path = ApacheVhost.DecidePHPPathforManager(request.GET.get('apache', None), phpVers)
|
||||
|
||||
allow_url_fopen = "0"
|
||||
display_errors = "0"
|
||||
@@ -1820,7 +1808,7 @@ def savePHPConfigBasic(request):
|
||||
else:
|
||||
allow_url_include = "allow_url_include = Off"
|
||||
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
#phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
|
||||
if request.GET.get('apache', None) == None:
|
||||
apache = 0
|
||||
@@ -1830,7 +1818,7 @@ def savePHPConfigBasic(request):
|
||||
##
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
|
||||
execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen +\
|
||||
execPath = execPath + " savePHPConfigBasic --phpVers '" + phpVers + "' --allow_url_fopen '" + allow_url_fopen +\
|
||||
"' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" \
|
||||
+ allow_url_include + "' --memory_limit " + memory_limit + " --max_execution_time " + \
|
||||
max_execution_time + " --upload_max_filesize " + upload_max_filesize \
|
||||
@@ -1875,24 +1863,8 @@ def getCurrentAdvancedPHPConfig(request):
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(f"apache value advanced config {request.GET.get('apache', None)}")
|
||||
|
||||
phpVersSApache = phpVers
|
||||
|
||||
if request.GET.get('apache', None) == None:
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(f"value of phpvers in ls {phpVers}")
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
final = phpVers[4]
|
||||
|
||||
completeName = str(initial) + '.' + str(final)
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
|
||||
else:
|
||||
path = f'/etc/php/{phpVersSApache.split(" ")[1]}/fpm/php.ini'
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(f'PHP Path {path}')
|
||||
from ApachController.ApacheVhosts import ApacheVhost
|
||||
path = ApacheVhost.DecidePHPPathforManager(request.GET.get('apache', None), phpVers)
|
||||
|
||||
command = "sudo cat " + path
|
||||
configData = ProcessUtilities.outputExecutioner(command)
|
||||
@@ -1926,20 +1898,8 @@ def savePHPConfigAdvance(request):
|
||||
phpVers = data['phpSelection']
|
||||
phpVersS = phpVers
|
||||
|
||||
if request.GET.get('apache', None) == None:
|
||||
phpVers = "php" + PHPManager.getPHPString(phpVers)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
final = phpVers[4]
|
||||
|
||||
completeName = str(initial) + '.' + str(final)
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
|
||||
else:
|
||||
path = f'/etc/php/{phpVersS.split(" ")[1]}/fpm/php.ini'
|
||||
if os.path.exists(ProcessUtilities.debugPath):
|
||||
logging.writeToFile(f'PHP Path {path}')
|
||||
from ApachController.ApacheVhosts import ApacheVhost
|
||||
path = ApacheVhost.DecidePHPPathforManager(request.GET.get('apache', None), phpVers)
|
||||
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
|
||||
@@ -108,19 +108,8 @@ class phpUtilities:
|
||||
command = 'touch %s' % (serverLevelPHPRestart)
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if int(apache) == 0:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
|
||||
else:
|
||||
initial = phpVers[3]
|
||||
final = phpVers[4]
|
||||
|
||||
completeName = str(initial) + '.' + str(final)
|
||||
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
|
||||
else:
|
||||
path = f'/etc/php/{phpVers[3]}.{phpVers[4]}/fpm/php.ini'
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(path)
|
||||
from ApachController.ApacheVhosts import ApacheVhost
|
||||
path = ApacheVhost.DecidePHPPathforManager(int(apache), phpVers)
|
||||
|
||||
data = open(path, 'r').readlines()
|
||||
|
||||
@@ -159,10 +148,7 @@ class phpUtilities:
|
||||
|
||||
if int(apache) == 1:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php{phpVers}-php-fpm'
|
||||
else:
|
||||
phpService = f"php{phpVers[3]}.{phpVers[4]}-fpm"
|
||||
phpService = ApacheVhost.DecideFPMServiceName(phpVers)
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
@@ -667,10 +667,7 @@ class vhost:
|
||||
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php{php}-php-fpm'
|
||||
else:
|
||||
phpService = f"{phpVersion.replace(' ', '').lower()}-fpm"
|
||||
phpService = ApacheVhost.DecideFPMServiceName(phpVersion)
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
@@ -245,10 +245,7 @@ class virtualHostUtilities:
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php{php}-php-fpm'
|
||||
else:
|
||||
phpService = f"{phpVersion.replace(' ', '').lower()}-fpm"
|
||||
phpService = ApacheVhost.DecideFPMServiceName(phpVersion)
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
@@ -1124,10 +1121,7 @@ class virtualHostUtilities:
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php{php}-php-fpm'
|
||||
else:
|
||||
phpService = f"{phpVersion.replace(' ', '').lower()}-fpm"
|
||||
phpService = ApacheVhost.DecideFPMServiceName(phpVersion)
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
@@ -1221,10 +1215,12 @@ class virtualHostUtilities:
|
||||
|
||||
##
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php{php}-php-fpm'
|
||||
else:
|
||||
phpService = f"{phpVersion.replace(' ', '').lower()}-fpm"
|
||||
phpService = ApacheVhost.DecideFPMServiceName(phpVersion)
|
||||
|
||||
# if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
# phpService = f'php{php}-php-fpm'
|
||||
# else:
|
||||
# phpService = f"{phpVersion.replace(' ', '').lower()}-fpm"
|
||||
|
||||
command = f"systemctl stop {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
@@ -4647,10 +4647,7 @@ StrictHostKeyChecking no
|
||||
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php{php}-php-fpm'
|
||||
else:
|
||||
phpService = f"{phpVersion.replace(' ', '').lower()}-fpm"
|
||||
phpService = ApacheVhost.DecideFPMServiceName(phpVersion)
|
||||
|
||||
command = f"systemctl stop {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
Reference in New Issue
Block a user