|
|
@ -119,9 +119,6 @@ def makeOpenrestyConf(version): |
|
|
|
|
|
|
|
|
|
|
|
dst_dir = sdir + '/web_conf/php' |
|
|
|
dst_dir = sdir + '/web_conf/php' |
|
|
|
dst_dir_conf = sdir + '/web_conf/php/conf' |
|
|
|
dst_dir_conf = sdir + '/web_conf/php/conf' |
|
|
|
dst_dir_status = sdir + '/web_conf/php/status' |
|
|
|
|
|
|
|
if not os.path.exists(dst_dir): |
|
|
|
|
|
|
|
mw.execShell('mkdir -p ' + dst_dir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(dst_dir_conf): |
|
|
|
if not os.path.exists(dst_dir_conf): |
|
|
|
mw.execShell('mkdir -p ' + dst_dir_conf) |
|
|
|
mw.execShell('mkdir -p ' + dst_dir_conf) |
|
|
@ -140,14 +137,6 @@ def makeOpenrestyConf(version): |
|
|
|
w_content = contentReplace(tpl_content, version) |
|
|
|
w_content = contentReplace(tpl_content, version) |
|
|
|
mw.writeFile(dfile, w_content) |
|
|
|
mw.writeFile(dfile, w_content) |
|
|
|
|
|
|
|
|
|
|
|
# php-fpm status |
|
|
|
|
|
|
|
dfile = sdir + '/web_conf/php/status/phpfpm_status_yum' + version + '.conf' |
|
|
|
|
|
|
|
tpl = getPluginDir() + '/conf/phpfpm_status.conf' |
|
|
|
|
|
|
|
if not os.path.exists(dfile): |
|
|
|
|
|
|
|
content = mw.readFile(tpl) |
|
|
|
|
|
|
|
content = contentReplace(content, version) |
|
|
|
|
|
|
|
mw.writeFile(dfile, content) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def phpFpmWwwReplace(version): |
|
|
|
def phpFpmWwwReplace(version): |
|
|
|
service_php_fpm_dir = getServerDir() + '/php' + version + '/php-fpm.d/' |
|
|
|
service_php_fpm_dir = getServerDir() + '/php' + version + '/php-fpm.d/' |
|
|
@ -175,7 +164,6 @@ def getFpmConfFile(version): |
|
|
|
def deleteConfList(version): |
|
|
|
def deleteConfList(version): |
|
|
|
sdir = mw.getServerDir() |
|
|
|
sdir = mw.getServerDir() |
|
|
|
enable_conf = sdir + '/web_conf/php/conf/enable-php-yum' + version + '.conf' |
|
|
|
enable_conf = sdir + '/web_conf/php/conf/enable-php-yum' + version + '.conf' |
|
|
|
status_conf = sdir + '/web_conf/php/status/phpfpm_status_yum' + version + '.conf' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clist = (status_conf, enable_conf) |
|
|
|
clist = (status_conf, enable_conf) |
|
|
|
for f in clist: |
|
|
|
for f in clist: |
|
|
@ -460,42 +448,46 @@ def setFpmConfig(version): |
|
|
|
return mw.returnJson(True, '设置成功!') |
|
|
|
return mw.returnJson(True, '设置成功!') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkFpmStatusFile(version): |
|
|
|
def getFpmAddress(version): |
|
|
|
if not mw.isInstalledWeb(): |
|
|
|
fpm_address = '/var/opt/remi/php{}/run/php-fpm/www.sock'.format(version) |
|
|
|
return False |
|
|
|
php_fpm_file = getFpmConfFile(version) |
|
|
|
|
|
|
|
try: |
|
|
|
dfile = getServerDir() + '/nginx/conf/php_status/phpfpm_status_yum' + version + '.conf' |
|
|
|
content = readFile(php_fpm_file) |
|
|
|
if not os.path.exists(dfile): |
|
|
|
tmp = re.findall(r"listen\s*=\s*(.+)", content) |
|
|
|
tpl = getPluginDir() + '/conf/phpfpm_status.conf' |
|
|
|
if not tmp: |
|
|
|
content = mw.readFile(tpl) |
|
|
|
return fpm_address |
|
|
|
content = contentReplace(content, version) |
|
|
|
if tmp[0].find('sock') != -1: |
|
|
|
mw.writeFile(dfile, content) |
|
|
|
return fpm_address |
|
|
|
mw.restartWeb() |
|
|
|
if tmp[0].find(':') != -1: |
|
|
|
return True |
|
|
|
listen_tmp = tmp[0].split(':') |
|
|
|
|
|
|
|
if bind: |
|
|
|
|
|
|
|
fpm_address = (listen_tmp[0], int(listen_tmp[1])) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
fpm_address = ('127.0.0.1', int(listen_tmp[1])) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
fpm_address = ('127.0.0.1', int(tmp[0])) |
|
|
|
|
|
|
|
return fpm_address |
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
return fpm_address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getFpmStatus(version): |
|
|
|
def getFpmStatus(version): |
|
|
|
|
|
|
|
|
|
|
|
checkFpmStatusFile(version) |
|
|
|
|
|
|
|
stat = status(version) |
|
|
|
stat = status(version) |
|
|
|
if stat == 'stop': |
|
|
|
if stat == 'stop': |
|
|
|
return mw.returnJson(False, 'PHP[' + version + ']未启动!!!') |
|
|
|
return mw.returnJson(False, 'PHP[' + version + ']未启动!!!') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sock_file = getFpmAddress(version) |
|
|
|
try: |
|
|
|
try: |
|
|
|
url = 'http://' + mw.getHostAddr() + '/phpfpm_status_yum' + version + '?json' |
|
|
|
sock_data = mw.requestFcgiPHP( |
|
|
|
result = mw.httpGet(url, 1) |
|
|
|
sock_file, '/phpfpm_status_yum' + version + '?json') |
|
|
|
data = json.loads(result) |
|
|
|
|
|
|
|
fTime = time.localtime(int(data['start time'])) |
|
|
|
|
|
|
|
data['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime) |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
|
|
|
|
url = 'http://127.0.0.1/phpfpm_status_yum' + version + '?json' |
|
|
|
|
|
|
|
result = mw.httpGet(url, 1) |
|
|
|
|
|
|
|
data = json.loads(result) |
|
|
|
|
|
|
|
fTime = time.localtime(int(data['start time'])) |
|
|
|
|
|
|
|
data['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime) |
|
|
|
|
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
data = {} |
|
|
|
return mw.returnJson(False, str(e)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print(data) |
|
|
|
|
|
|
|
result = str(sock_data, encoding='utf-8') |
|
|
|
|
|
|
|
data = json.loads(result) |
|
|
|
|
|
|
|
fTime = time.localtime(int(data['start time'])) |
|
|
|
|
|
|
|
data['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime) |
|
|
|
return mw.returnJson(True, "OK", data) |
|
|
|
return mw.returnJson(True, "OK", data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -532,32 +524,24 @@ def setDisableFunc(version): |
|
|
|
return mw.returnJson(True, '设置成功!') |
|
|
|
return mw.returnJson(True, '设置成功!') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkPhpinfoFile(v): |
|
|
|
def getPhpinfo(version): |
|
|
|
sdir = mw.getServerDir() |
|
|
|
stat = status(version) |
|
|
|
dfile = sdir + '/web_conf/php/status/phpinfo_' + v + '.conf' |
|
|
|
if stat == 'stop': |
|
|
|
tpl = getPluginDir() + '/conf/phpinfo.conf' |
|
|
|
return mw.returnJson(False, 'PHP[' + version + ']未启动!!!') |
|
|
|
content = mw.readFile(tpl) |
|
|
|
|
|
|
|
content = contentReplace(content, v) |
|
|
|
sock_file = getFpmAddress(version) |
|
|
|
mw.writeFile(dfile, content) |
|
|
|
root_dir = mw.getRootDir() + '/phpinfo' |
|
|
|
mw.restartWeb() |
|
|
|
|
|
|
|
|
|
|
|
mw.execShell("rm -rf " + root_dir) |
|
|
|
|
|
|
|
mw.execShell("mkdir -p " + root_dir) |
|
|
|
def getPhpinfo(v): |
|
|
|
mw.writeFile(root_dir + '/phpinfo.php', '<?php phpinfo(); ?>') |
|
|
|
checkPhpinfoFile(v) |
|
|
|
sock_data = mw.requestFcgiPHP(sock_file, '/phpinfo.php', root_dir) |
|
|
|
sPath = mw.getRootDir() + '/phpinfo/' + v |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mw.execShell("rm -rf " + mw.getRootDir() + '/phpinfo') |
|
|
|
|
|
|
|
mw.execShell("mkdir -p " + sPath) |
|
|
|
|
|
|
|
mw.writeFile(sPath + '/phpinfo.php', '<?php phpinfo(); ?>') |
|
|
|
|
|
|
|
url = 'http://127.0.0.1/' + v + '/phpinfo.php' |
|
|
|
|
|
|
|
phpinfo = mw.httpGet(url) |
|
|
|
|
|
|
|
os.system("rm -rf " + mw.getRootDir() + '/phpinfo') |
|
|
|
os.system("rm -rf " + mw.getRootDir() + '/phpinfo') |
|
|
|
|
|
|
|
phpinfo = str(sock_data, encoding='utf-8') |
|
|
|
return phpinfo |
|
|
|
return phpinfo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_php_info(args): |
|
|
|
def get_php_info(args): |
|
|
|
if not mw.isInstalledWeb(): |
|
|
|
|
|
|
|
return "openresty is not running!!!" |
|
|
|
|
|
|
|
return getPhpinfo(args['version']) |
|
|
|
return getPhpinfo(args['version']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|