pull/109/head
midoks 6 years ago
parent 65351bd24d
commit 834f708654
  1. 22
      class/core/site_api.py
  2. 51
      data/tpl/nginx.conf

@ -19,7 +19,18 @@ class site_api:
isWriteLogs = None # 是否写日志 isWriteLogs = None # 是否写日志
def __init__(self): def __init__(self):
pass self.setupPath = public.getServerDir()
path = self.setupPath + '/openresty/nginx/conf/vhost'
if not os.path.exists(path):
public.execShell("mkdir -p " + path + " && chmod -R 644 " + path)
path = self.setupPath + '/openresty/nginx/conf/rewrite'
if not os.path.exists(path):
public.execShell("mkdir -p " + path + " && chmod -R 644 " + path)
path = self.setupPath + '/stop'
if not os.path.exists(path):
os.system('mkdir -p ' + path)
# os.system('wget -O ' + path + '/index.html ' +
# public.get_url() + '/stop.html &')
# 域名编码转换 # 域名编码转换
def toPunycode(self, domain): def toPunycode(self, domain):
@ -94,8 +105,11 @@ class site_api:
def createRootDir(self, path): def createRootDir(self, path):
if not os.path.exists(path): if not os.path.exists(path):
os.makedirs(path) os.makedirs(path)
print public.execShell('chown -R www:www ' + path)
public.execShell('chmod -R 755 ' + path) public.execShell('chmod -R 755 ' + path)
public.execShell('chown -R www:www ' + path)
def nginxAddConf(self):
pass
def add(self, webname, port, ps, path, version): def add(self, webname, port, ps, path, version):
@ -110,8 +124,12 @@ class site_api:
pid = public.M('sites').add('name,path,status,ps,edate,addtime', pid = public.M('sites').add('name,path,status,ps,edate,addtime',
(self.siteName, self.sitePath, '1', ps, '0000-00-00', public.getDate())) (self.siteName, self.sitePath, '1', ps, '0000-00-00', public.getDate()))
self.createRootDir(self.sitePath)
# public.M('domain').add('pid,name,port,addtime', # public.M('domain').add('pid,name,port,addtime',
# (get.pid, self.siteName, self.sitePort, public.getDate())) # (get.pid, self.siteName, self.sitePort, public.getDate()))
self.nginxAddConf()
data = {} data = {}
data['siteStatus'] = False data['siteStatus'] = False
return public.getJson(data) return public.getJson(data)

@ -0,0 +1,51 @@
server
{
listen %s;
server_name %s;
index index.php index.html index.htm default.php default.htm default.html;
root %s;
#SSL-START %s
#error_page 404/404.html;
#SSL-END
#ERROR-PAGE-START %s
error_page 404 /404.html;
error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START %s
include enable-php-%s.conf;
#PHP-INFO-END
#REWRITE-START %s
include %s/panel/vhost/rewrite/%s.conf;
#REWRITE-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
access_log /dev/null;
}
location ~ .*\\.(js|css)?$
{
expires 12h;
error_log off;
access_log /dev/null;
}
access_log %s.log;
error_log %s.error.log;
}
Loading…
Cancel
Save