Skip to content

Commit

Permalink
7.5.22
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Oct 27, 2020
1 parent 1fd1e09 commit 1f8f7dc
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 59 deletions.
28 changes: 25 additions & 3 deletions BTPanel/static/js/soft.js
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ var soft = {
{ type: 'set_upload_limit', val: ver, title: lan.soft.php_main2 },
{ type: 'set_timeout_limit', val: ver, title: lan.soft.php_main3, php53: true },
{ type: 'config', val: ver, title: lan.soft.php_main4 },
{ type: 'fpm_config', val: ver, title: 'FPM配置文件' },
{ type: 'set_dis_fun', val: ver, title: lan.soft.php_main6 },
{ type: 'set_fpm_config', val: ver, title: lan.soft.php_main7, apache24: true, php53: true },
{ type: 'get_php_status', val: ver, title: lan.soft.php_main8, apache24: true, php53: true },
Expand Down Expand Up @@ -980,6 +981,23 @@ var soft = {
bt.saveEditor(config);
});
break;
case 'fpm_config':
var tabCon = $(".soft-man-con").empty();
tabCon.append('<p style="color: #666; margin-bottom: 7px">' + lan.bt.edit_ps + '</p>');
tabCon.append('<div class="bt-input-text ace_config_editor_scroll" style="height: 320px;min-height:350px;line-height:18px;" id="textBody"></div>')
tabCon.append('<button id="OnlineEditFileBtn" class="btn btn-success btn-sm" style="margin-top:10px;">' + lan.public.save + '</button>')
var _arry = ['此处为PHP-FPM配置文件,若您不了解配置规则,请勿修改!'];
tabCon.append(bt.render_help(_arry))
$('.return_php_info').click(function(){
$('.bt-soft-menu p:eq(12)').click();
});
var fileName = bt.soft.get_config_path(version).replace('php.ini','php-fpm.conf');
var loadT = bt.load(lan.soft.get);
var config = bt.aceEditor({el:'textBody',path:fileName});
$("#OnlineEditFileBtn").click(function () {
bt.saveEditor(config);
});
break;
case 'change_version':
var _list = [];
var opt_version = '';
Expand Down Expand Up @@ -1994,6 +2012,12 @@ var soft = {
for (var sk in item) $('.' + sk).val(item[sk]);
}
},
{
title: '连接方式', name: 'listen', value: rdata.unix, type: 'select', items: [
{ title: 'Unix套接字', value: 'unix' },
{ title: 'TCP套接字', value: 'tcp' }
], ps: '* 推荐Unix套接字'
},
{
title: lan.soft.php_fpm_model, name: 'pm', value: rdata.pm, type: 'select', items: [
{ title: lan.bt.static, value: 'static' },
Expand Down Expand Up @@ -2057,8 +2081,6 @@ var soft = {
<li>【静态模式】始终维持设置的子进程数量,对内存开销较大,但并发能力较好</li>\
<li>【动态模式】按设置最大空闲进程数来收回进程,内存开销小,建议小内存机器使用</li>\
<li>【按需模式】根据访问需求自动创建进程,内存开销极小,但并发能力略差</li>\
<li>【多PHP版本】若您安装了多个PHP版本,且都在使用,建议适当降低并发配置</li>\
<li>【没有数据库】若没有安装mysql等数据库,建议设置2倍于推荐并发</li>\
<li>【注意】以上为建议配置说明,线上项目复杂多样,请根据实际情况酌情调整</li>\
</ul>')
tabCon.append(_c_form);
Expand Down Expand Up @@ -2527,7 +2549,7 @@ function AddSite(codename,title) {
<p><span>密码:</span><strong>" + rdata.msg.admin_password + "</strong></p>\
"
}
sqlData += "<p><span>访问站点:</span><a class='btlink' href='http://" + mainDomain + rdata.msg.success_url + "' target='_blank' rel='noreferrer noopener'>http://" + mainDomain + (rdata.msg.success_url.indexOf('/')== 0?rdata.msg.success_url:'/'+rdata.msg.success_url) + "</a></p>";
sqlData += "<p><span>访问站点:</span><a class='btlink' href='http://" + (mainDomain +'/'+ rdata.msg.success_url).replace('//','/') + "' target='_blank' rel='noreferrer noopener'>http://" + (mainDomain +'/'+ rdata.msg.success_url).replace('//','/') + "</a></p>";

layer.open({
type: 1,
Expand Down
14 changes: 7 additions & 7 deletions class/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def set_phpmyadmin_ssl(self,get):
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-{}.sock|fcgi://localhost"
SetHandler "proxy:{}"
</FilesMatch>
#DENY FILES
Expand All @@ -827,7 +827,7 @@ def set_phpmyadmin_ssl(self,get):
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>'''.format(v["ext"]["phpversion"])
</VirtualHost>'''.format(public.get_php_proxy(v["ext"]["phpversion"],'apache'))
public.writeFile("/www/server/panel/vhost/apache/phpmyadmin.conf", ssl_conf)
else:
if os.path.exists("/www/server/panel/vhost/nginx/phpmyadmin.conf"):
Expand All @@ -839,7 +839,7 @@ def set_phpmyadmin_ssl(self,get):
public.serviceReload()
return public.returnMsg(True,'开启成功,请手动放行phpmyadmin ssl端口')


#设置PHPMyAdmin
def setPHPMyAdmin(self,get):
import re
Expand Down Expand Up @@ -889,11 +889,11 @@ def setPHPMyAdmin(self,get):
if public.get_webserver() == 'nginx':
filename = public.GetConfigValue('setup_path') + '/nginx/conf/enable-php.conf'
conf = public.readFile(filename)
rep = r"php-cgi.*\.sock"
conf = re.sub(rep,'php-cgi-' + get.phpversion + '.sock',conf,1)
rep = r"(unix:/tmp/php-cgi.*\.sock|127.0.0.1:\d+)"
conf = re.sub(rep,public.get_php_proxy(get.phpversion,'nginx'),conf,1)
elif public.get_webserver() == 'apache':
rep = r"php-cgi.*\.sock"
conf = re.sub(rep,'php-cgi-' + get.phpversion + '.sock',conf,1)
rep = r"(unix:/tmp/php-cgi.*\.sock\|fcgi://localhost|fcgi://127.0.0.1:\d+)"
conf = re.sub(rep,public.get_php_proxy(get.phpversion,'apache'),conf,1)
else:
reg = r'/usr/local/lsws/lsphp\d+/bin/lsphp'
conf = re.sub(reg,'/usr/local/lsws/lsphp{}/bin/lsphp'.format(get.phpversion),conf)
Expand Down
13 changes: 13 additions & 0 deletions class/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,9 @@ def getFpmConfig(self,get):
rep = r"\s*pm\s*=\s*(\w+)\s*"
tmp = re.search(rep, conf).groups()
data['pm'] = tmp[0]
data['unix'] = 'unix'
if not isinstance(public.get_fpm_address(version),str):
data['unix'] = 'tcp'

return data

Expand Down Expand Up @@ -559,9 +562,19 @@ def setFpmConfig(self,get):
if conf.find('listen.backlog = -1') != -1:
rep = r"\s*listen\.backlog\s*=\s*([0-9-]+)\s*"
conf = re.sub(rep, "\nlisten.backlog = 8192\n", conf)

if get.listen == 'unix':
listen = '/tmp/php-cgi-{}.sock'.format(version)
else:
listen = '127.0.0.1:10{}1'.format(version)


rep = r'\s*listen\s*=\s*.+\s*'
conf = re.sub(rep, "\nlisten = "+listen+"\n", conf)

public.writeFile(file,conf)
public.phpReload(version)
public.sync_php_address(version)
public.WriteLog("TYPE_PHP",'PHP_CHILDREN', (version,max_children,start_servers,min_spare_servers,max_spare_servers))
return public.returnMsg(True, 'SET_SUCCESS')

Expand Down
2 changes: 1 addition & 1 deletion class/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def GetDir(self, get):
dirnames.append(filename+';'+size+';' +
mtime+';'+accept+';'+user+';'+link + ';' +self.get_download_id(filePath)+';'+ self.is_composer_json(filePath))
else:
filenames.append(filename+';'+size+';'+mtime+';'+accept+';'+user+';'+link+';'+self.get_download_id(filePath))
filenames.append(filename+';'+size+';'+mtime+';'+accept+';'+user+';'+link+';'+self.get_download_id(filePath)+';' + self.is_composer_json(filePath))
n += 1
except:
continue
Expand Down
1 change: 1 addition & 0 deletions class/panelPHP.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ def load_url(self, url, content=b''):
@param content stream(POST数据io对象)
@return fastcgi-socket
'''

fcgi = fcgi_client.FCGIApp(connect=self.fcgi_sock)
try:
script_name, query_string = url.split('?')
Expand Down
51 changes: 38 additions & 13 deletions class/panelPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ def get_cloud_list(self,get=None):
cloudUrl = public.GetConfigValue('home') + '/api/panel/get_soft_list_test'
import panelAuth
pdata = panelAuth.panelAuth().create_serverid(None)
listTmp = public.httpPost(cloudUrl,pdata,10)
listTmp = public.httpPost(cloudUrl,pdata,6)
if not listTmp or len(listTmp) < 200:
listTmp = public.readFile(lcoalTmp)
try:
softList = json.loads(listTmp)
except: pass
if softList: public.writeFile(lcoalTmp,json.dumps(softList))
public.ExecShell('rm -f /tmp/bmac_*')
self.getCloudPHPExt(get)
public.run_thread(self.getCloudPHPExt)
self.expire_msg(softList)
try:
public.writeFile("/tmp/" + cache.get('p_token'),str(softList['pro']))
Expand Down Expand Up @@ -625,7 +625,6 @@ def check_accept(self,get):
#取软件列表
def get_soft_list(self,get = None):
softList = self.get_cloud_list(get)

if not softList:
get.force = 1
softList = self.get_cloud_list(get)
Expand Down Expand Up @@ -797,7 +796,6 @@ def check_isinstall(self,sList):
def check_status(self,softInfo):
softInfo['setup'] = os.path.exists(softInfo['install_checks'])
softInfo['status'] = False

softInfo['task'] = self.check_setup_task(softInfo['name'])

if softInfo['name'].find('php-') != -1: softInfo['fpm'] = False
Expand Down Expand Up @@ -833,7 +831,7 @@ def check_status(self,softInfo):
if softInfo['name'].find('php-') != -1:
v2= softInfo['versions'][0]['m_version'].replace('.','')
softInfo['fpm'] = os.path.exists('/www/server/php/' + v2 + '/sbin/php-fpm')
softInfo['status'] = os.path.exists('/tmp/php-cgi-'+v2+'.sock')
softInfo['status'] = self.get_php_status(v2)
pid_file = '/www/server/php/' + v2 + '/var/run/php-fpm.pid'
if not softInfo['fpm']:
softInfo['status'] = True
Expand All @@ -846,7 +844,9 @@ def check_status(self,softInfo):
if os.path.exists(pid_file):
os.remove(pid_file)

if softInfo['name'] == 'mysql': softInfo['status'] = self.process_exists('mysqld')
if softInfo['name'] == 'mysql':
softInfo['status'] = self.process_exists('mysqld')
if not softInfo['status']: softInfo['status'] = self.process_exists('mariadbd')
if softInfo['name'] == 'phpmyadmin': softInfo['status'] = self.get_phpmyadmin_stat()
if softInfo['name'] == 'openlitespeed':
if public.ExecShell('ps aux|grep openlitespeed|grep -v "grep"')[0]:
Expand All @@ -855,6 +855,26 @@ def check_status(self,softInfo):
softInfo['status'] = False
return softInfo

def get_php_status(self,phpversion):
'''
@name 获取指定PHP版本的服务状态
@author hwliang<2020-10-23>
@param phpversion string PHP版本
@return bool
'''
try:
php_status = os.path.exists('/tmp/php-cgi-'+phpversion+'.sock')
if php_status: return php_status
pid_file = '/www/server/php/{}/var/run/php-fpm.pid'.format(phpversion)
if not os.path.exists(pid_file): return False
pid = int(public.readFile(pid_file))
return os.path.exists('/proc/{}/comm'.format(pid))
except:
return False




#取phpmyadmin状态
def get_phpmyadmin_stat(self):
if public.get_webserver() == 'nginx':
Expand Down Expand Up @@ -1218,7 +1238,7 @@ def install(self,get):

if pluginInfo['tip'] == 'lib':
if not os.path.exists(self.__install_path + '/' + pluginInfo['name']): public.ExecShell('mkdir -p ' + self.__install_path + '/' + pluginInfo['name'])
if not 'download_url' in session: session['download_url'] = 'http://download.bt.cn'
if not 'download_url' in session: session['download_url'] = public.get_url()
download_url = session['download_url'] + '/install/plugin/' + pluginInfo['name'] + '/install.sh'
toFile = self.__install_path + '/' + pluginInfo['name'] + '/install.sh'
public.downloadFile(download_url,toFile)
Expand Down Expand Up @@ -1602,9 +1622,14 @@ def getPHPMyAdminStatus(self):
if rtmp:
phpversion = rtmp.groups()[0]
else:
rep = r"php-cgi.*\.sock"
public.writeFile(configFile,conf)
phpversion = '54'
rep = r'127.0.0.1:10(\d{2,2})1'
rtmp = re.findall(rep,conf)
if rtmp:
phpversion = rtmp[0]
else:
rep = r"php-cgi.*\.sock"
public.writeFile(configFile,conf)
phpversion = '54'

configFile = setupPath + '/apache/conf/extra/httpd-vhosts.conf'
if os.path.exists(configFile):
Expand Down Expand Up @@ -1836,12 +1861,12 @@ def flush_cache(self,get):
return public.returnMsg(True,'软件列表已更新!')

#获取PHP扩展
def getCloudPHPExt(self,get):
def getCloudPHPExt(self,get = None):
import json
try:
key = 'php_ext_cache'
if cache.get(key): return 1
surl = 'http://download.bt.cn'
surl = public.get_url()
download_url = surl + '/install/lib/phplib.json'
tstr = public.httpGet(download_url)
data = json.loads(tstr)
Expand Down Expand Up @@ -1878,7 +1903,7 @@ def getCloudPHPExt(self,get):
#获取警告列表
def GetCloudWarning(self,get):
import json
if not session.get('download_url'): session['download_url'] = 'http://download.bt.cn'
if not session.get('download_url'): session['download_url'] = public.get_url()
download_url = session['download_url'] + '/install/warning.json'
tstr = public.httpGet(download_url)
data = json.loads(tstr)
Expand Down
Loading

0 comments on commit 1f8f7dc

Please sign in to comment.