mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
apache manager
This commit is contained in:
@@ -293,12 +293,11 @@ LoadModule mpm_event_module modules/mod_mpm_event.so
|
||||
if ProcessUtilities.executioner(command, None, True) == 0:
|
||||
return "Failed to ppa:ondrej/php"
|
||||
|
||||
command = "sudo apt-get install -y php-fpm php7.4-fpm php8.0-fpm php7.4-mysql php7.4-curl php7.4-gd php7.4-mbstring php7.4-xml php7.4-zip php8.0-mysql php8.0-curl php8.0-gd php8.0-mbstring php8.0-xml php8.0-zip"
|
||||
command = "DEBIAN_FRONTEND=noninteractive apt-get install -y php-fpm php?.?-fpm php?.?-fpm php?.?-mysql php?.?-curl php?.?-gd php?.?-mbstring php?.?-xml php?.?-zip"
|
||||
|
||||
if ProcessUtilities.executioner(command, None, True) == 0:
|
||||
return "Failed to install Apache and PHP-FPM."
|
||||
|
||||
|
||||
try:
|
||||
wwwConfPath = ApacheVhost.php54Path + "/www.conf"
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ class ApacheVhost:
|
||||
php72Path = '/etc/opt/remi/php72/php-fpm.d/'
|
||||
php73Path = '/etc/opt/remi/php73/php-fpm.d/'
|
||||
|
||||
serviceName = 'httpd'
|
||||
|
||||
else:
|
||||
serverRootPath = '/etc/apache2'
|
||||
configBasePath = '/etc/apache2/sites-enabled/'
|
||||
@@ -46,6 +48,8 @@ class ApacheVhost:
|
||||
php81Path = '/etc/php/8.1/fpm/pool.d/'
|
||||
php82Path = '/etc/php/8.2/fpm/pool.d/'
|
||||
|
||||
serviceName = 'apache2'
|
||||
|
||||
|
||||
|
||||
lswsMainConf = "/usr/local/lsws/conf/httpd_config.conf"
|
||||
@@ -139,8 +143,10 @@ class ApacheVhost:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
sockPath = '/var/run/php-fpm/'
|
||||
group = 'nobody'
|
||||
else:
|
||||
sockPath = '/var/run/php/'
|
||||
group = 'nogroup'
|
||||
|
||||
## Non-SSL Conf
|
||||
|
||||
@@ -191,12 +197,13 @@ class ApacheVhost:
|
||||
currentConf = currentConf.replace('{Sock}', virtualHostName)
|
||||
currentConf = currentConf.replace('{externalApp}', externalApp)
|
||||
currentConf = currentConf.replace('{sockPath}', sockPath)
|
||||
currentConf = currentConf.replace('{group}', group)
|
||||
|
||||
confFile.write(currentConf)
|
||||
|
||||
ApacheVhost.GenerateSelfSignedSSL(virtualHostName)
|
||||
|
||||
command = "systemctl restart httpd"
|
||||
command = f"systemctl restart {ApacheVhost.serviceName}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
return [1, 'None']
|
||||
@@ -262,8 +269,10 @@ class ApacheVhost:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
sockPath = '/var/run/php-fpm/'
|
||||
group = 'nobody'
|
||||
else:
|
||||
sockPath = '/var/run/php/'
|
||||
group = 'nogroup'
|
||||
|
||||
finalConfPath = ApacheVhost.configBasePath + virtualHostName + '.conf'
|
||||
confFile = open(finalConfPath, "w+")
|
||||
@@ -312,12 +321,13 @@ class ApacheVhost:
|
||||
currentConf = currentConf.replace('{Sock}', virtualHostName)
|
||||
currentConf = currentConf.replace('{externalApp}', externalApp)
|
||||
currentConf = currentConf.replace('{sockPath}', sockPath)
|
||||
currentConf = currentConf.replace('{group}', group)
|
||||
|
||||
confFile.write(currentConf)
|
||||
|
||||
ApacheVhost.GenerateSelfSignedSSL(virtualHostName)
|
||||
|
||||
command = "systemctl restart httpd"
|
||||
command = f"systemctl restart {ApacheVhost.serviceName}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
return [1, 'None']
|
||||
@@ -326,6 +336,7 @@ class ApacheVhost:
|
||||
|
||||
@staticmethod
|
||||
def setupApacheVhostChild(administratorEmail, externalApp, virtualHostUser, phpVersion, virtualHostName, path):
|
||||
|
||||
result = ApacheVhost.perHostVirtualConfChild(administratorEmail, externalApp, virtualHostUser, phpVersion,
|
||||
virtualHostName, path)
|
||||
if result[0] == 0:
|
||||
@@ -347,7 +358,7 @@ class ApacheVhost:
|
||||
|
||||
ApacheVhost.deletePHPPath(virtualHostName)
|
||||
|
||||
command = "systemctl restart httpd"
|
||||
command = f"systemctl restart {ApacheVhost.serviceName}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
except BaseException as msg:
|
||||
@@ -375,59 +386,154 @@ class ApacheVhost:
|
||||
phpPath = ApacheVhost.DecidePHPPath('54', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
command = "systemctl restart php%s-php-fpm" % ('54')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php54-php-fpm'
|
||||
else:
|
||||
phpService = f"php5.4-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('55', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
|
||||
os.remove(phpPath)
|
||||
command = "systemctl restart php%s-php-fpm" % ('55')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php55-php-fpm'
|
||||
else:
|
||||
phpService = f"php5.5-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('56', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
command = "systemctl restart php%s-php-fpm" % ('56')
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php56-php-fpm'
|
||||
else:
|
||||
phpService = f"php5.6-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('70', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
command = "systemctl restart php%s-php-fpm" % ('70')
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php70-php-fpm'
|
||||
else:
|
||||
phpService = f"php7.0-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('71', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
command = "systemctl restart php%s-php-fpm" % ('71')
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php71-php-fpm'
|
||||
else:
|
||||
phpService = f"php7.1-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('72', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
command = "systemctl restart php%s-php-fpm" % ('72')
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php72-php-fpm'
|
||||
else:
|
||||
phpService = f"php7.2-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('73', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
command = "systemctl restart php%s-php-fpm" % ('73')
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php73-php-fpm'
|
||||
else:
|
||||
phpService = f"php7.3-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('74', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php74-php-fpm'
|
||||
else:
|
||||
phpService = f"php7.4-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('80', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php80-php-fpm'
|
||||
else:
|
||||
phpService = f"php8.0-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('81', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php81-php-fpm'
|
||||
else:
|
||||
phpService = f"php8.1-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
phpPath = ApacheVhost.DecidePHPPath('82', virtualHostName)
|
||||
if os.path.exists(phpPath):
|
||||
os.remove(phpPath)
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
phpService = f'php82-php-fpm'
|
||||
else:
|
||||
phpService = f"php8.2-fpm"
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
@staticmethod
|
||||
def changePHP(phpVersion, vhFile):
|
||||
try:
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
sockPath = '/var/run/php-fpm/'
|
||||
group = 'nobody'
|
||||
else:
|
||||
sockPath = '/var/run/php/'
|
||||
group = 'nogroup'
|
||||
|
||||
virtualHostName = vhFile.split('/')[6]
|
||||
|
||||
finalConfPath = ApacheVhost.configBasePath + virtualHostName + '.conf'
|
||||
|
||||
if not os.path.exists(finalConfPath):
|
||||
logging.writeToFile(f'Config path: {finalConfPath}')
|
||||
return 0
|
||||
|
||||
ApacheVhost.deletePHPPath(virtualHostName)
|
||||
|
||||
try:
|
||||
website = Websites.objects.get(domain=virtualHostName)
|
||||
externalApp = website.externalApp
|
||||
except:
|
||||
child = ChildDomains.objects.get(domain=virtualHostName)
|
||||
externalApp = child.master.externalApp
|
||||
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
|
||||
@@ -435,16 +541,26 @@ class ApacheVhost:
|
||||
|
||||
confFile = open(finalConfPath, "w+")
|
||||
currentConf = vhostConfs.phpFpmPool
|
||||
currentConf = currentConf.replace('{www}', website.externalApp)
|
||||
currentConf = currentConf.replace('{www}', externalApp)
|
||||
currentConf = currentConf.replace('{Sock}', virtualHostName)
|
||||
currentConf = currentConf.replace('{externalApp}', website.externalApp)
|
||||
currentConf = currentConf.replace('{externalApp}', externalApp)
|
||||
currentConf = currentConf.replace('{sockPath}', sockPath)
|
||||
currentConf = currentConf.replace('{group}', group)
|
||||
|
||||
confFile.write(currentConf)
|
||||
|
||||
command = "systemctl stop php%s-php-fpm" % (php)
|
||||
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)
|
||||
|
||||
command = "systemctl restart php%s-php-fpm" % (php)
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
command = f"systemctl restart {ApacheVhost.serviceName}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
return 1
|
||||
|
||||
@@ -618,8 +618,17 @@ class vhost:
|
||||
def changePHP(vhFile, phpVersion):
|
||||
|
||||
from pathlib import Path
|
||||
HomePath = Path("/home/%s" % (vhFile.split('/')[-2]))
|
||||
virtualHostUser = HomePath.owner()
|
||||
domain = vhFile.split('/')[6]
|
||||
print(domain)
|
||||
try:
|
||||
website = Websites.objects.get(domain=domain)
|
||||
externalApp = website.externalApp
|
||||
except:
|
||||
child = ChildDomains.objects.get(domain=domain)
|
||||
externalApp = child.master.externalApp
|
||||
#HomePath = website.externalApp
|
||||
virtualHostUser = externalApp
|
||||
|
||||
phpDetachUpdatePath = '/home/%s/.lsphp_restart.txt' % (vhFile.split('/')[-2])
|
||||
if ProcessUtilities.decideServer() == ProcessUtilities.OLS:
|
||||
try:
|
||||
@@ -657,7 +666,13 @@ class vhost:
|
||||
logging.CyberCPLogFileWriter.writeToFile('apache vhost 1')
|
||||
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
command = "systemctl restart php%s-php-fpm" % (php)
|
||||
|
||||
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 restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
print("1,None")
|
||||
|
||||
@@ -385,7 +385,7 @@ REWRITERULE ^(.*)$ HTTP://proxyApacheBackendSSL/$1 [P,L]
|
||||
phpFpmPool = """[{www}]
|
||||
listen = {sockPath}{Sock}.sock
|
||||
listen.owner = nobody
|
||||
listen.group = nobody
|
||||
listen.group = {group}
|
||||
listen.mode = 0660
|
||||
user = {externalApp}
|
||||
group = {externalApp}
|
||||
@@ -398,7 +398,7 @@ pm.max_spare_servers = 1
|
||||
phpFpmPoolReplace = """[{www}]
|
||||
listen = {sockPath}{Sock}.sock
|
||||
listen.owner = nobody
|
||||
listen.group = nobody
|
||||
listen.group = {group}
|
||||
listen.mode = 0660
|
||||
user = {externalApp}
|
||||
group = {externalApp}
|
||||
|
||||
@@ -244,7 +244,13 @@ class virtualHostUtilities:
|
||||
ApacheVhost.perHostVirtualConfOLS(completePathToConfigFile, administratorEmail)
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
command = "systemctl restart php%s-php-fpm" % (php)
|
||||
|
||||
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 restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
## Create Configurations ends here
|
||||
@@ -437,6 +443,29 @@ class virtualHostUtilities:
|
||||
str(msg) + " [saveVHostConfigs]")
|
||||
print("0," + str(msg))
|
||||
|
||||
@staticmethod
|
||||
def saveApacheConfigsToFile(fileName, tempPath):
|
||||
try:
|
||||
|
||||
vhost = open(fileName, "w")
|
||||
|
||||
vhost.write(open(tempPath, "r").read())
|
||||
|
||||
vhost.close()
|
||||
|
||||
if os.path.exists(tempPath):
|
||||
os.remove(tempPath)
|
||||
|
||||
command = f"systemctl restart {ApacheVhost.serviceName}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
print("1,None")
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + " [saveApacheConfigsToFile]")
|
||||
print("0," + str(msg))
|
||||
|
||||
@staticmethod
|
||||
def saveRewriteRules(virtualHost, fileName, tempPath):
|
||||
try:
|
||||
@@ -1094,7 +1123,13 @@ class virtualHostUtilities:
|
||||
ApacheVhost.perHostVirtualConfOLS(completePathToConfigFile, master.adminEmail)
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
command = "systemctl restart php%s-php-fpm" % (php)
|
||||
|
||||
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 restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
## DKIM Check
|
||||
@@ -1183,8 +1218,25 @@ class virtualHostUtilities:
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Restarting servers and phps..,90')
|
||||
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
command = "systemctl restart php%s-php-fpm" % (php)
|
||||
|
||||
##
|
||||
|
||||
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)
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
command = f"systemctl restart {ApacheVhost.serviceName}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
###
|
||||
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Successfully converted.[200]')
|
||||
else:
|
||||
@@ -1561,6 +1613,8 @@ def main():
|
||||
virtualHostUtilities.getErrorLogs(args.path, int(args.page))
|
||||
elif args.function == "saveVHostConfigs":
|
||||
virtualHostUtilities.saveVHostConfigs(args.path, args.tempPath)
|
||||
elif args.function == "saveApacheConfigsToFile":
|
||||
virtualHostUtilities.saveApacheConfigsToFile(args.path, args.tempPath)
|
||||
elif args.function == "saveRewriteRules":
|
||||
virtualHostUtilities.saveRewriteRules(args.virtualHostName, args.path, args.tempPath)
|
||||
elif args.function == "saveSSL":
|
||||
|
||||
@@ -4518,7 +4518,7 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
||||
$scope.currentStatus = "Starting creation..";
|
||||
$scope.DomainCreateForm = true;
|
||||
|
||||
var ssl, dkimCheck, openBasedir;
|
||||
var ssl, dkimCheck, openBasedir, apacheBackend;
|
||||
|
||||
if ($scope.sslCheck === true) {
|
||||
ssl = 1;
|
||||
@@ -4539,6 +4539,13 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
||||
}
|
||||
|
||||
|
||||
if ($scope.apacheBackend === true) {
|
||||
apacheBackend = 1;
|
||||
} else {
|
||||
apacheBackend = 0
|
||||
}
|
||||
|
||||
|
||||
url = "/websites/submitDomainCreation";
|
||||
var domainName = $scope.domainNameCreate;
|
||||
var phpSelection = $scope.phpSelection;
|
||||
@@ -4567,7 +4574,8 @@ app.controller('websitePages', function ($scope, $http, $timeout, $window) {
|
||||
path: path,
|
||||
masterDomain: $scope.masterDomain,
|
||||
dkimCheck: dkimCheck,
|
||||
openBasedir: openBasedir
|
||||
openBasedir: openBasedir,
|
||||
apacheBackend: apacheBackend
|
||||
};
|
||||
|
||||
var config = {
|
||||
@@ -9694,3 +9702,284 @@ app.controller('manageGIT', function ($scope, $http, $timeout, $window) {
|
||||
});
|
||||
|
||||
/* Java script code to git tracking ends here */
|
||||
|
||||
|
||||
app.controller('ApacheManager', function ($scope, $http, $timeout) {
|
||||
$scope.cyberpanelloading = true;
|
||||
$scope.apacheOLS = true;
|
||||
$scope.pureOLS = true;
|
||||
$scope.lswsEnt = true;
|
||||
|
||||
var apache = 1, ols = 2, lsws = 3;
|
||||
var statusFile;
|
||||
|
||||
$scope.getSwitchStatus = function () {
|
||||
$scope.cyberpanelloading = false;
|
||||
url = "/websites/getSwitchStatus";
|
||||
|
||||
var data = {
|
||||
domainName: $("#domainNamePage").text()
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelloading = true;
|
||||
if (response.data.status === 1) {
|
||||
if (response.data.server === apache) {
|
||||
$scope.apacheOLS = false;
|
||||
$scope.pureOLS = true;
|
||||
$scope.lswsEnt = true;
|
||||
$scope.configData = response.data.configData;
|
||||
|
||||
$scope.pmMaxChildren = response.data.pmMaxChildren;
|
||||
$scope.pmStartServers = response.data.pmStartServers;
|
||||
$scope.pmMinSpareServers = response.data.pmMinSpareServers;
|
||||
$scope.pmMaxSpareServers = response.data.pmMaxSpareServers;
|
||||
$scope.phpPath = response.data.phpPath;
|
||||
|
||||
|
||||
} else if (response.data.server === ols) {
|
||||
$scope.apacheOLS = true;
|
||||
$scope.pureOLS = false;
|
||||
$scope.lswsEnt = true;
|
||||
} else {
|
||||
$scope.apacheOLS = true;
|
||||
$scope.pureOLS = true;
|
||||
$scope.lswsEnt = false;
|
||||
}
|
||||
//$scope.records = JSON.parse(response.data.data);
|
||||
} else {
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelloading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
$scope.getSwitchStatus();
|
||||
|
||||
$scope.switchServer = function (server) {
|
||||
$scope.cyberpanelloading = false;
|
||||
$scope.functionProgress = {"width": "0%"};
|
||||
$scope.functionStatus = 'Starting conversion..';
|
||||
|
||||
url = "/websites/switchServer";
|
||||
|
||||
var data = {
|
||||
domainName: $("#domainNamePage").text(),
|
||||
phpSelection: $scope.phpSelection,
|
||||
server: server
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
if (response.data.status === 1) {
|
||||
statusFile = response.data.tempStatusPath;
|
||||
statusFunc();
|
||||
|
||||
} else {
|
||||
$scope.cyberpanelloading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelloading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
function statusFunc() {
|
||||
$scope.cyberpanelloading = false;
|
||||
url = "/websites/statusFunc";
|
||||
|
||||
var data = {
|
||||
statusFile: statusFile
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
|
||||
function ListInitialData(response) {
|
||||
if (response.data.status === 1) {
|
||||
if (response.data.abort === 1) {
|
||||
$scope.functionProgress = {"width": "100%"};
|
||||
$scope.functionStatus = response.data.currentStatus;
|
||||
$scope.cyberpanelloading = true;
|
||||
$timeout.cancel();
|
||||
$scope.getSwitchStatus();
|
||||
} else {
|
||||
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
|
||||
$scope.functionStatus = response.data.currentStatus;
|
||||
$timeout(statusFunc, 3000);
|
||||
}
|
||||
|
||||
} else {
|
||||
$scope.cyberpanelloading = true;
|
||||
$scope.functionStatus = response.data.error_message;
|
||||
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
|
||||
$timeout.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.functionProgress = {"width": response.data.installationProgress + "%"};
|
||||
$scope.functionStatus = 'Could not connect to server, please refresh this page.';
|
||||
$timeout.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$scope.tuneSettings = function () {
|
||||
$scope.cyberpanelloading = false;
|
||||
|
||||
url = "/websites/tuneSettings";
|
||||
|
||||
var data = {
|
||||
domainName: $("#domainNamePage").text(),
|
||||
pmMaxChildren: $scope.pmMaxChildren,
|
||||
pmStartServers: $scope.pmStartServers,
|
||||
pmMinSpareServers: $scope.pmMinSpareServers,
|
||||
pmMaxSpareServers: $scope.pmMaxSpareServers,
|
||||
phpPath: $scope.phpPath
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelloading = true;
|
||||
if (response.data.status === 1) {
|
||||
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Changes successfully applied.',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
} else {
|
||||
$scope.cyberpanelloading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelloading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$scope.saveApacheConfig = function () {
|
||||
$scope.cyberpanelloading = false;
|
||||
|
||||
url = "/websites/saveApacheConfigsToFile";
|
||||
|
||||
var data = {
|
||||
domainName: $("#domainNamePage").text(),
|
||||
configData: $scope.configData
|
||||
};
|
||||
|
||||
var config = {
|
||||
headers: {
|
||||
'X-CSRFToken': getCookie('csrftoken')
|
||||
}
|
||||
};
|
||||
|
||||
$http.post(url, data, config).then(ListInitialData, cantLoadInitialData);
|
||||
|
||||
function ListInitialData(response) {
|
||||
$scope.cyberpanelloading = true;
|
||||
if (response.data.status === 1) {
|
||||
|
||||
new PNotify({
|
||||
title: 'Success',
|
||||
text: 'Changes successfully applied.',
|
||||
type: 'success'
|
||||
});
|
||||
|
||||
} else {
|
||||
$scope.cyberpanelloading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: response.data.error_message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cantLoadInitialData(response) {
|
||||
$scope.cyberpanelloading = true;
|
||||
new PNotify({
|
||||
title: 'Operation Failed!',
|
||||
text: 'Could not connect to server, please refresh this page.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
218
websiteFunctions/templates/websiteFunctions/ApacheManager.html
Executable file
218
websiteFunctions/templates/websiteFunctions/ApacheManager.html
Executable file
@@ -0,0 +1,218 @@
|
||||
{% extends "baseTemplate/index.html" %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Apache Manager - CyberPanel" %}{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{% load static %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
||||
|
||||
<div class="container">
|
||||
<div id="page-title">
|
||||
<h2>{% trans "Apache Manager" %}</h2>
|
||||
<p>{% trans "Switch between Apache (as reverse proxy) and OpenLiteSpeed." %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div ng-controller="ApacheManager" class="panel">
|
||||
<div class="panel-body">
|
||||
<h3 class="title-hero">
|
||||
<span id="domainNamePage">{{ domainName }}</span> <img ng-hide="cyberpanelloading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h3>
|
||||
|
||||
<div class="card card-body">
|
||||
<h5 ng-hide="apacheOLS" class="card-title">{{ domainName }} is currently using Apache as Reverse
|
||||
Proxy to
|
||||
OpenLiteSpeed. <img
|
||||
style="height: 25px" ng-hide="cyberpanelloading"
|
||||
src="{% static 'images/loading.gif' %}"></h5>
|
||||
<!-- Using Apache -->
|
||||
<div ng-hide="apacheOLS" class="row">
|
||||
<div class="col-md-12">
|
||||
<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 %}
|
||||
<option>{{ php }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
<a data-toggle="modal" data-target="#bs-example-modal-lg" ng-hide="apacheOLS"
|
||||
ng-click="switchServer(2)" href="#" class="btn btn-primary">Switch to pure
|
||||
OpenLiteSpeed.</a>
|
||||
|
||||
|
||||
<div ng-hide="apacheOLS" class="col-md-12">
|
||||
|
||||
<form style="margin-top: 2%" class="form-horizontal bordered-row">
|
||||
|
||||
<div class="form-group">
|
||||
<h3 style="margin-bottom: 2%" ng-hide="apacheOLS">Apache Configurations</h3>
|
||||
<div class="col-sm-12">
|
||||
<textarea ng-model="configData" rows="20" class="form-control"></textarea>
|
||||
</div>
|
||||
<div ng-hide="saveConfigBtn" class="form-group">
|
||||
<div style="margin: 2%" class="col-sm-4">
|
||||
<button type="button" ng-click="saveApacheConfig()"
|
||||
class="btn btn-primary btn-lg">{% trans "Save Apache Configurations" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Tune FPM -->
|
||||
|
||||
<div class="card card-body">
|
||||
<h3 style="margin-bottom: 2%" ng-hide="apacheOLS">PHP-FPM Configurations <img
|
||||
style="height: 25px" ng-hide="cyberpanelloading"
|
||||
src="{% static 'images/loading.gif' %}"></h3>
|
||||
<!-- Using Apache -->
|
||||
<form ng-hide="apacheOLS">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="billing-town-city">pm.max_children</label>
|
||||
<input class="form-control" type="text"
|
||||
ng-model="pmMaxChildren"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="billing-town-city">pm.start_servers</label>
|
||||
<input class="form-control" type="text"
|
||||
ng-model="pmStartServers"/>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="billing-town-city">pm.min_spare_servers</label>
|
||||
<input class="form-control" type="text"
|
||||
ng-model="pmMinSpareServers"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="billing-town-city">pm.max_spare_servers</label>
|
||||
<input class="form-control" type="text"
|
||||
ng-model="pmMaxSpareServers"/>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
</form>
|
||||
<a ng-hide="apacheOLS" ng-click="tuneSettings()"
|
||||
href="#" class="btn btn-primary">Tune PHP-FPM Settings.</a>
|
||||
<!-- Using OpenLiteSpeed -->
|
||||
<p ng-hide="pureOLS" class="card-text">{{ domainName }} is currently using pure
|
||||
OpenLiteSpeed, PHP-FPM
|
||||
is
|
||||
not used with OpenLiteSpeed, thus tuning is disabled.</p>
|
||||
<!-- Using OpenLiteSpeed -->
|
||||
<p ng-hide="lswsEnt" class="card-text">{{ domainName }} is using LiteSpeed Enterprise.
|
||||
PHP-FPM is not
|
||||
used
|
||||
with LiteSpeed
|
||||
Enterprise.</p>
|
||||
</div> <!-- end card-->
|
||||
|
||||
<!-- Modal content for the above example -->
|
||||
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myLargeModalLabel">{$ functionStatus $} <img
|
||||
style="height: 25px"
|
||||
ng-hide="cyberpanelloading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-hidden="true">×
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="progress">
|
||||
<div ng-style="functionProgress"
|
||||
class="progress-bar progress-bar-striped bg-info"
|
||||
role="progressbar"
|
||||
aria-valuenow="50" aria-valuemin="0"
|
||||
aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<!-- Tune FPM End -->
|
||||
|
||||
</div>
|
||||
<!-- Using OpenLiteSpeed -->
|
||||
<p ng-hide="pureOLS" class="card-text">{{ domainName }} is currently using pure OpenLiteSpeed.</p>
|
||||
<div ng-hide="pureOLS" class="row">
|
||||
<div class="col-md-12">
|
||||
<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 %}
|
||||
<option>{{ php }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end row -->
|
||||
<a data-toggle="modal" data-target="#bs-example-modal-lg" ng-hide="pureOLS"
|
||||
ng-click="switchServer(1)" href="#" class="btn btn-primary">Switch to OpenLiteSpeed +
|
||||
Apache
|
||||
as reverse proxy.</a>
|
||||
<!-- Using OpenLiteSpeed -->
|
||||
<p ng-hide="lswsEnt" class="card-text">{{ domainName }} is using LiteSpeed Enterprise. When
|
||||
LiteSpeed
|
||||
Enterprise is active switching is not required.</p>
|
||||
</div> <!-- end card-->
|
||||
|
||||
<!-- Modal content for the above example -->
|
||||
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myLargeModalLabel">{$ functionStatus $} <img
|
||||
style="height: 25px"
|
||||
ng-hide="cyberpanelloading"
|
||||
src="{% static 'images/loading.gif' %}">
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-hidden="true">×
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="progress">
|
||||
<div ng-style="functionProgress"
|
||||
class="progress-bar progress-bar-striped bg-info"
|
||||
role="progressbar"
|
||||
aria-valuenow="50" aria-valuemin="0"
|
||||
aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
@@ -264,6 +264,16 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input ng-model="apacheBackend" type="checkbox" value="">
|
||||
Apache as Backend
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="checkbox">
|
||||
|
||||
@@ -26,13 +26,17 @@
|
||||
|
||||
<h3 class="content-box-header">
|
||||
{% trans "Resource Usage" %}
|
||||
<a style="float: right; margin-left: 2%" class="btn btn-border btn-alt border-orange btn-link font-orange" href="/websites/{{ childDomain }}/manageGIT" title="Manage Git"><span>{% trans "Manage Git" %}</span></a>
|
||||
<a style="float: right; margin-left: 2%"
|
||||
class="btn btn-border btn-alt border-orange btn-link font-orange"
|
||||
href="/websites/{{ childDomain }}/manageGIT"
|
||||
title="Manage Git"><span>{% trans "Manage Git" %}</span></a>
|
||||
<a style="float: right; margin-left: 2%"
|
||||
class="btn btn-border btn-alt border-azure btn-link font-azure"
|
||||
href="/websites/{{ domain }}/{{ childDomain }}/syncToMaster"
|
||||
title=""><span>{% trans "Copy/Sync to Master" %}</span></a>
|
||||
<a style="float: right" class="btn btn-border btn-alt border-black btn-link font-black"
|
||||
href="https://go.cyberpanel.net/StessTest" title=""><span>{% trans "Stress Test" %}</span></a>
|
||||
href="https://go.cyberpanel.net/StessTest"
|
||||
title=""><span>{% trans "Stress Test" %}</span></a>
|
||||
</h3>
|
||||
|
||||
<div class="">
|
||||
@@ -277,6 +281,17 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 panel-body">
|
||||
<a href="{% url 'ApacheManager' domain=domain %}"
|
||||
title="{% trans 'Apache Manager' %}">
|
||||
<img src="{% static 'images/icons/file.png' %}" width="65" class="mr-10">
|
||||
</a>
|
||||
<a href="{% url 'ApacheManager' domain=childDomain %}"
|
||||
title="{% trans 'Apache Manager' %}">
|
||||
<span class="h4">{% trans "Apache Manager" %}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 panel-body">
|
||||
|
||||
<a ng-click="fetchRewriteFules()" href=""
|
||||
@@ -690,17 +705,17 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# <div class="col-md-3 panel-body">#}
|
||||
{##}
|
||||
{# <a href="{$ joomlaInstallURL $}" target="_blank"#}
|
||||
{# title="{% trans 'Install Joomla with LSCache' %}">#}
|
||||
{# <img src="{% static 'images/icons/joomla-logo.png' %}" width="65" class="mr-10">#}
|
||||
{# </a>#}
|
||||
{# <a href="{$ joomlaInstallURL $}" target="_blank"#}
|
||||
{# title="{% trans 'Install Joomla with LSCache' %}">#}
|
||||
{# <span class="h4">{% trans "Joomla" %}</span>#}
|
||||
{# </a>#}
|
||||
{# </div>#}
|
||||
{# <div class="col-md-3 panel-body">#}
|
||||
{##}
|
||||
{# <a href="{$ joomlaInstallURL $}" target="_blank"#}
|
||||
{# title="{% trans 'Install Joomla with LSCache' %}">#}
|
||||
{# <img src="{% static 'images/icons/joomla-logo.png' %}" width="65" class="mr-10">#}
|
||||
{# </a>#}
|
||||
{# <a href="{$ joomlaInstallURL $}" target="_blank"#}
|
||||
{# title="{% trans 'Install Joomla with LSCache' %}">#}
|
||||
{# <span class="h4">{% trans "Joomla" %}</span>#}
|
||||
{# </a>#}
|
||||
{# </div>#}
|
||||
|
||||
<div class="col-md-3 panel-body">
|
||||
<a href="/websites/{{ childDomain }}/manageGIT" target="_blank"
|
||||
@@ -728,16 +743,16 @@
|
||||
</div>
|
||||
|
||||
|
||||
{# <div class="col-md-3 panel-body">#}
|
||||
{# <a href="{$ installMagentoURL $}" target="_blank"#}
|
||||
{# title="{% trans 'Install Magento' %}">#}
|
||||
{# <img src="{% static 'images/icons/magento.png' %}" width="65" class="mr-10">#}
|
||||
{# </a>#}
|
||||
{# <a href="{$ installMagentoURL $}" target="_blank"#}
|
||||
{# title="{% trans 'Install Magento' %}">#}
|
||||
{# <span class="h4">{% trans "Magento" %}</span>#}
|
||||
{# </a>#}
|
||||
{# </div>#}
|
||||
{# <div class="col-md-3 panel-body">#}
|
||||
{# <a href="{$ installMagentoURL $}" target="_blank"#}
|
||||
{# title="{% trans 'Install Magento' %}">#}
|
||||
{# <img src="{% static 'images/icons/magento.png' %}" width="65" class="mr-10">#}
|
||||
{# </a>#}
|
||||
{# <a href="{$ installMagentoURL $}" target="_blank"#}
|
||||
{# title="{% trans 'Install Magento' %}">#}
|
||||
{# <span class="h4">{% trans "Magento" %}</span>#}
|
||||
{# </a>#}
|
||||
{# </div>#}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -532,6 +532,17 @@
|
||||
</h3>
|
||||
<div class="content-box-wrapper">
|
||||
<div class="row mx-10">
|
||||
<div class="col-md-3 panel-body">
|
||||
<a href="{% url 'ApacheManager' domain=domain %}"
|
||||
title="{% trans 'Apache Manager' %}">
|
||||
<img src="{% static 'images/icons/file.png' %}" width="65" class="mr-10">
|
||||
</a>
|
||||
<a href="{% url 'ApacheManager' domain=domain %}"
|
||||
title="{% trans 'Apache Manager' %}">
|
||||
<span class="h4">{% trans "Apache Manager" %}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 panel-body">
|
||||
<a ng-click="fetchConfigurations()" href=""
|
||||
title="{% trans 'Edit vHost Main Configurations' %}">
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from django.conf.urls import url
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.loadWebsitesHome, name='loadWebsitesHome'),
|
||||
url(r'^createWebsite$', views.createWebsite, name='createWebsite'),
|
||||
@@ -15,7 +14,6 @@ urlpatterns = [
|
||||
|
||||
url(r'^CreateNewDomain$', views.CreateNewDomain, name='CreateNewDomain'),
|
||||
|
||||
|
||||
### WordPress
|
||||
url(r'^createWordpress$', views.WPCreate, name='createWordpress'),
|
||||
url(r'^ListWPSites$', views.ListWPSites, name='ListWPSites'),
|
||||
@@ -28,7 +26,6 @@ urlpatterns = [
|
||||
url(r'^AddRemoteBackupsite$', views.AddRemoteBackupsite, name='AddRemoteBackupsite'),
|
||||
url(r'^pricing$', views.WordpressPricing, name='pricing'),
|
||||
|
||||
|
||||
###WordPress Ajax
|
||||
url(r'^submitWorpressCreation', views.submitWorpressCreation, name='submitWorpressCreation'),
|
||||
url(r'^FetchWPdata', views.FetchWPdata, name='FetchWPdata'),
|
||||
@@ -56,26 +53,19 @@ urlpatterns = [
|
||||
url(r'^UpdateRemoteschedules', views.UpdateRemoteschedules, name='UpdateRemoteschedules'),
|
||||
url(r'^ScanWordpressSite', views.ScanWordpressSite, name='ScanWordpressSite'),
|
||||
|
||||
|
||||
|
||||
|
||||
#### AddPlugin
|
||||
url(r'^ConfigurePlugins$', views.ConfigurePlugins, name='ConfigurePlugins'),
|
||||
url(r'^Addnewplugin$', views.Addnewplugin, name='Addnewplugin'),
|
||||
url(r'^EidtPlugin$', views.EidtPlugin, name='EidtPlugin'),
|
||||
|
||||
|
||||
|
||||
## AddPlugin Ajax
|
||||
url(r'^SearchOnkeyupPlugin$', views.SearchOnkeyupPlugin, name='SearchOnkeyupPlugin'),
|
||||
url(r'^AddNewpluginAjax$', views.AddNewpluginAjax, name='AddNewpluginAjax'),
|
||||
url(r'^deletesPlgin', views.deletesPlgin, name='deletesPlgin'),
|
||||
url(r'^Addplugineidt', views.Addplugineidt, name='Addplugineidt'),
|
||||
|
||||
|
||||
# Website modification url
|
||||
|
||||
|
||||
url(r'^submitWebsiteCreation$', views.submitWebsiteCreation, name='submitWebsiteCreation'),
|
||||
url(r'^submitWebsiteDeletion$', views.submitWebsiteDeletion, name='submitWebsiteDeletion'),
|
||||
url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'),
|
||||
@@ -86,7 +76,6 @@ urlpatterns = [
|
||||
url(r'^submitWebsiteModification$', views.deleteWebsite, name='submitWebsiteModification'),
|
||||
url(r'^submitWebsiteStatus$', views.submitWebsiteStatus, name='submitWebsiteStatus'),
|
||||
|
||||
|
||||
url(r'^getWebsiteDetails$', views.submitWebsiteModify, name='getWebsiteDetails'),
|
||||
url(r'^saveWebsiteChanges', views.saveWebsiteChanges, name='saveWebsiteChanges'),
|
||||
|
||||
@@ -97,7 +86,6 @@ urlpatterns = [
|
||||
|
||||
url(r'^saveConfigsToFile$', views.saveConfigsToFile, name='saveConfigsToFile'),
|
||||
|
||||
|
||||
url(r'^getRewriteRules$', views.getRewriteRules, name='getRewriteRules'),
|
||||
|
||||
url(r'^saveRewriteRules$', views.saveRewriteRules, name='saveRewriteRules'),
|
||||
@@ -116,32 +104,29 @@ urlpatterns = [
|
||||
url(r'^searchChilds$', views.searchChilds, name='searchChilds'),
|
||||
# crons
|
||||
|
||||
url(r'^listCron$',views.listCron,name="listCron"),
|
||||
url(r'^getWebsiteCron$',views.getWebsiteCron,name="getWebsiteCron"),
|
||||
url(r'^getCronbyLine$',views.getCronbyLine,name="getCronbyLine"),
|
||||
url(r'^remCronbyLine$',views.remCronbyLine,name="remCronbyLine"),
|
||||
url(r'^saveCronChanges$',views.saveCronChanges,name="saveCronChanges"),
|
||||
url(r'^addNewCron$',views.addNewCron,name="addNewCron"),
|
||||
|
||||
url(r'^listCron$', views.listCron, name="listCron"),
|
||||
url(r'^getWebsiteCron$', views.getWebsiteCron, name="getWebsiteCron"),
|
||||
url(r'^getCronbyLine$', views.getCronbyLine, name="getCronbyLine"),
|
||||
url(r'^remCronbyLine$', views.remCronbyLine, name="remCronbyLine"),
|
||||
url(r'^saveCronChanges$', views.saveCronChanges, name="saveCronChanges"),
|
||||
url(r'^addNewCron$', views.addNewCron, name="addNewCron"),
|
||||
|
||||
## Domain Alias
|
||||
|
||||
url(r'^(?P<domain>(.*))/domainAlias$', views.domainAlias, name='domainAlias'),
|
||||
url(r'^submitAliasCreation$',views.submitAliasCreation,name="submitAliasCreation"),
|
||||
url(r'^issueAliasSSL$',views.issueAliasSSL,name="issueAliasSSL"),
|
||||
url(r'^delateAlias$',views.delateAlias,name="delateAlias"),
|
||||
|
||||
url(r'^submitAliasCreation$', views.submitAliasCreation, name="submitAliasCreation"),
|
||||
url(r'^issueAliasSSL$', views.issueAliasSSL, name="issueAliasSSL"),
|
||||
url(r'^delateAlias$', views.delateAlias, name="delateAlias"),
|
||||
|
||||
## Openbasedir
|
||||
url(r'^changeOpenBasedir$',views.changeOpenBasedir,name="changeOpenBasedir"),
|
||||
url(r'^changeOpenBasedir$', views.changeOpenBasedir, name="changeOpenBasedir"),
|
||||
|
||||
## WP Install
|
||||
|
||||
url(r'^(?P<domain>(.*))/wordpressInstall$', views.wordpressInstall, name='wordpressInstall'),
|
||||
url(r'^installWordpressStatus$',views.installWordpressStatus,name="installWordpressStatus"),
|
||||
url(r'^installWordpressStatus$', views.installWordpressStatus, name="installWordpressStatus"),
|
||||
url(r'^installWordpress$', views.installWordpress, name='installWordpress'),
|
||||
|
||||
|
||||
## Joomla Install
|
||||
|
||||
url(r'^installJoomla$', views.installJoomla, name='installJoomla'),
|
||||
@@ -162,7 +147,6 @@ urlpatterns = [
|
||||
url(r'^(?P<domain>(.*))/installMautic$', views.installMautic, name='installMautic'),
|
||||
url(r'^mauticInstall$', views.mauticInstall, name='mauticInstall'),
|
||||
|
||||
|
||||
## Git
|
||||
url(r'^(?P<domain>(.*))/setupGit$', views.setupGit, name='setupGit'),
|
||||
url(r'^setupGitRepo$', views.setupGitRepo, name='setupGitRepo'),
|
||||
@@ -178,7 +162,6 @@ urlpatterns = [
|
||||
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))/syncToMaster$', views.syncToMaster, name='syncToMaster'),
|
||||
url(r'^startSync$', views.startSync, name='startSync'),
|
||||
|
||||
|
||||
url(r'^(?P<domain>(.*))/gitNotify$', views.gitNotify, name='gitNotify'),
|
||||
url(r'^detachRepo$', views.detachRepo, name='detachRepo'),
|
||||
url(r'^changeBranch$', views.changeBranch, name='changeBranch'),
|
||||
@@ -211,8 +194,17 @@ urlpatterns = [
|
||||
url(r'^deleteSSHKey$', views.deleteSSHKey, name='deleteSSHKey'),
|
||||
url(r'^addSSHKey$', views.addSSHKey, name='addSSHKey'),
|
||||
|
||||
### Apache Manager
|
||||
|
||||
url(r'^ApacheManager/(?P<domain>(.*))$', views.ApacheManager, name='ApacheManager'),
|
||||
url(r'^getSwitchStatus$', views.getSwitchStatus, name='getSwitchStatus'),
|
||||
url(r'^switchServer$', views.switchServer, name='switchServer'),
|
||||
url(r'^statusFunc$', views.statusFunc, name='statusFunc'),
|
||||
url(r'^tuneSettings$', views.tuneSettings, name='tuneSettings'),
|
||||
url(r'^saveApacheConfigsToFile$', views.saveApacheConfigsToFile, name='saveApacheConfigsToFile'),
|
||||
|
||||
## Catch all for domains
|
||||
url(r'^(?P<domain>(.*))/(?P<childDomain>(.*))$', views.launchChild, name='launchChild'),
|
||||
url(r'^(?P<domain>(.*))$', views.domain, name='domain'),
|
||||
|
||||
]
|
||||
@@ -1695,3 +1695,58 @@ def webhook(request, domain):
|
||||
return wm.webhook(domain, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def ApacheManager(request, domain):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager(domain)
|
||||
return wm.ApacheManager(request, userID)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
|
||||
def getSwitchStatus(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.getSwitchStatus(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def switchServer(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
wm = WebsiteManager()
|
||||
return wm.switchServer(userID, json.loads(request.body))
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def statusFunc(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
data = json.loads(request.body)
|
||||
from cloudAPI.cloudManager import CloudManager
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
cm = CloudManager(data, admin)
|
||||
return cm.statusFunc()
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def tuneSettings(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
data = json.loads(request.body)
|
||||
wm = WebsiteManager()
|
||||
return wm.tuneSettings(userID, data)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
def saveApacheConfigsToFile(request):
|
||||
try:
|
||||
userID = request.session['userID']
|
||||
data = json.loads(request.body)
|
||||
wm = WebsiteManager()
|
||||
return wm.saveApacheConfigsToFile(userID, data)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
|
||||
@@ -4527,6 +4527,7 @@ StrictHostKeyChecking no
|
||||
data['pmMinSpareServers'] = pmMinSpareServers
|
||||
data['pmMaxSpareServers'] = pmMaxSpareServers
|
||||
data['phpPath'] = phpPath
|
||||
data['configData'] = ProcessUtilities.outputExecutioner(f'cat {finalConfPath}')
|
||||
else:
|
||||
data = {}
|
||||
data['status'] = 1
|
||||
@@ -4572,6 +4573,7 @@ StrictHostKeyChecking no
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def tuneSettings(self, userID=None, data=None):
|
||||
try:
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
@@ -4608,6 +4610,13 @@ StrictHostKeyChecking no
|
||||
|
||||
tempStatusPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
sockPath = '/var/run/php-fpm/'
|
||||
group = 'nobody'
|
||||
else:
|
||||
sockPath = '/var/run/php/'
|
||||
group = 'nogroup'
|
||||
|
||||
phpFPMConf = vhostConfs.phpFpmPoolReplace
|
||||
phpFPMConf = phpFPMConf.replace('{externalApp}', externalApp)
|
||||
phpFPMConf = phpFPMConf.replace('{pmMaxChildren}', pmMaxChildren)
|
||||
@@ -4616,6 +4625,8 @@ StrictHostKeyChecking no
|
||||
phpFPMConf = phpFPMConf.replace('{pmMaxSpareServers}', pmMaxSpareServers)
|
||||
phpFPMConf = phpFPMConf.replace('{www}', "".join(re.findall("[a-zA-Z]+", domainName))[:7])
|
||||
phpFPMConf = phpFPMConf.replace('{Sock}', domainName)
|
||||
phpFPMConf = phpFPMConf.replace('{sockPath}', sockPath)
|
||||
phpFPMConf = phpFPMConf.replace('{group}', group)
|
||||
|
||||
writeToFile = open(tempStatusPath, 'w')
|
||||
writeToFile.writelines(phpFPMConf)
|
||||
@@ -4626,20 +4637,34 @@ StrictHostKeyChecking no
|
||||
|
||||
phpPath = phpPath.split('/')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
if phpPath[1] == 'etc':
|
||||
phpVersion = phpPath[4][3] + phpPath[4][4]
|
||||
else:
|
||||
phpVersion = phpPath[3][3] + phpPath[3][4]
|
||||
else:
|
||||
phpVersion = f'PHP {phpPath[2]}'
|
||||
|
||||
command = "systemctl stop php%s-php-fpm" % (phpVersion)
|
||||
ProcessUtilities.executioner(command)
|
||||
php = PHPManager.getPHPString(phpVersion)
|
||||
|
||||
command = "systemctl restart php%s-php-fpm" % (phpVersion)
|
||||
ProcessUtilities.executioner(command)
|
||||
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)
|
||||
|
||||
command = f"systemctl restart {phpService}"
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
data_ret = {'status': 1}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
except BaseException as msg:
|
||||
data_ret = {'status': 0, 'error_message': str(msg)}
|
||||
json_data = json.dumps(data_ret)
|
||||
return HttpResponse(json_data)
|
||||
|
||||
def sshAccess(self, request=None, userID=None, data=None):
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
@@ -6396,3 +6421,58 @@ StrictHostKeyChecking no
|
||||
final_dic = {'status': 0, 'add_status': 0, 'error_mssage': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
|
||||
def ApacheManager(self, request=None, userID=None, data=None):
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
admin = Administrator.objects.get(pk=userID)
|
||||
|
||||
if ACLManager.checkOwnership(self.domain, admin, currentACL) == 1:
|
||||
pass
|
||||
else:
|
||||
return ACLManager.loadError()
|
||||
|
||||
phps = PHPManager.findPHPVersions()
|
||||
|
||||
proc = httpProc(request, 'websiteFunctions/ApacheManager.html', {'domainName': self.domain, 'phps': phps})
|
||||
return proc.render()
|
||||
|
||||
def saveApacheConfigsToFile(self, userID=None, data=None):
|
||||
|
||||
currentACL = ACLManager.loadedACL(userID)
|
||||
|
||||
if currentACL['admin'] != 1:
|
||||
return ACLManager.loadErrorJson('configstatus', 0)
|
||||
|
||||
configData = data['configData']
|
||||
self.domain = data['domainName']
|
||||
|
||||
mailUtilities.checkHome()
|
||||
|
||||
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))
|
||||
|
||||
vhost = open(tempPath, "w")
|
||||
|
||||
vhost.write(configData)
|
||||
|
||||
vhost.close()
|
||||
|
||||
## writing data temporary to file
|
||||
|
||||
filePath = ApacheVhost.configBasePath + self.domain + '.conf'
|
||||
|
||||
## save configuration data
|
||||
|
||||
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py"
|
||||
execPath = execPath + " saveApacheConfigsToFile --path " + filePath + " --tempPath " + tempPath
|
||||
|
||||
output = ProcessUtilities.outputExecutioner(execPath)
|
||||
|
||||
if output.find("1,None") > -1:
|
||||
status = {"status": 1}
|
||||
final_json = json.dumps(status)
|
||||
return HttpResponse(final_json)
|
||||
else:
|
||||
final_dic = {'status': 0, 'error_message': output}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
Reference in New Issue
Block a user