diff --git a/ApachController/ApacheController.py b/ApachController/ApacheController.py index 8c8bac732..6890602ce 100755 --- a/ApachController/ApacheController.py +++ b/ApachController/ApacheController.py @@ -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' diff --git a/ApachController/ApacheVhosts.py b/ApachController/ApacheVhosts.py index 8fc50256f..689bca886 100755 --- a/ApachController/ApacheVhosts.py +++ b/ApachController/ApacheVhosts.py @@ -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) @@ -571,4 +568,37 @@ class ApacheVhost: return 1 except BaseException as msg: logging.writeToFile(str(msg)) - return 1 \ No newline at end of file + 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" \ No newline at end of file diff --git a/managePHP/views.py b/managePHP/views.py index 81b3ae6de..96631c08d 100755 --- a/managePHP/views.py +++ b/managePHP/views.py @@ -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)) diff --git a/plogical/phpUtilities.py b/plogical/phpUtilities.py index 99cac9e9d..ff567bc56 100755 --- a/plogical/phpUtilities.py +++ b/plogical/phpUtilities.py @@ -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) diff --git a/plogical/vhost.py b/plogical/vhost.py index ba5fc34fc..1cff43495 100755 --- a/plogical/vhost.py +++ b/plogical/vhost.py @@ -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) diff --git a/plogical/virtualHostUtilities.py b/plogical/virtualHostUtilities.py index 80e008bb0..e0b63d5c8 100644 --- a/plogical/virtualHostUtilities.py +++ b/plogical/virtualHostUtilities.py @@ -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) diff --git a/websiteFunctions/website.py b/websiteFunctions/website.py index 043c1f58d..6cfa3160c 100755 --- a/websiteFunctions/website.py +++ b/websiteFunctions/website.py @@ -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)