openresty和php配置文件分离
This commit is contained in:
parent
f54cba80f6
commit
ffd22d384b
|
|
@ -1660,6 +1660,7 @@ class site_api:
|
|||
content = content.replace('{$PORT}', self.sitePort)
|
||||
content = content.replace('{$SERVER_NAME}', self.siteName)
|
||||
content = content.replace('{$ROOT_DIR}', self.sitePath)
|
||||
content = content.replace('{$PHP_DIR}', self.setupPath + '/php')
|
||||
content = content.replace('{$PHPVER}', self.phpVersion)
|
||||
content = content.replace('{$OR_REWRITE}', self.rewritePath)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ server
|
|||
#ERROR-PAGE-END
|
||||
|
||||
#PHP-INFO-START
|
||||
include enable-php-{$PHPVER}.conf;
|
||||
include {$PHP_DIR}/conf/enable-php-{$PHPVER}.conf;
|
||||
#PHP-INFO-END
|
||||
|
||||
#REWRITE-START
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ http
|
|||
stub_status on;
|
||||
access_log off;
|
||||
}
|
||||
include {$SERVER_PATH}/openresty/nginx/conf/php_status/*.conf;
|
||||
include {$SERVER_PATH}/web_conf/php/status/*.conf;
|
||||
}
|
||||
include {$SERVER_PATH}/web_conf/nginx/vhost/*.conf;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ location ~ [^/]\.php(/|$)
|
|||
fastcgi_pass unix:/tmp/php-cgi-{$PHP_VERSION}.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
include pathinfo.conf;
|
||||
include {$SERVER_PATH}/web_conf/php/pathinfo.conf;
|
||||
}
|
||||
|
|
@ -122,37 +122,49 @@ def contentReplace(content, version):
|
|||
def makeOpenrestyConf():
|
||||
phpversions = ['00', '52', '53', '54', '55', '56',
|
||||
'70', '71', '72', '73', '74', '80', '81']
|
||||
if mw.isInstalledWeb():
|
||||
sdir = mw.getServerDir()
|
||||
d_pathinfo = sdir + '/openresty/nginx/conf/pathinfo.conf'
|
||||
if not os.path.exists(d_pathinfo):
|
||||
s_pathinfo = getPluginDir() + '/conf/pathinfo.conf'
|
||||
shutil.copyfile(s_pathinfo, d_pathinfo)
|
||||
|
||||
info = getPluginDir() + '/info.json'
|
||||
content = mw.readFile(info)
|
||||
content = json.loads(content)
|
||||
versions = content['versions']
|
||||
tpl = getPluginDir() + '/conf/enable-php.conf'
|
||||
tpl_content = mw.readFile(tpl)
|
||||
for x in phpversions:
|
||||
dfile = sdir + '/openresty/nginx/conf/enable-php-' + x + '.conf'
|
||||
if not os.path.exists(dfile):
|
||||
if x == '00':
|
||||
mw.writeFile(dfile, '')
|
||||
else:
|
||||
w_content = contentReplace(tpl_content, x)
|
||||
mw.writeFile(dfile, w_content)
|
||||
sdir = mw.getServerDir()
|
||||
|
||||
# php-fpm status
|
||||
for version in phpversions:
|
||||
dfile = sdir + '/openresty/nginx/conf/php_status/phpfpm_status_' + 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)
|
||||
mw.restartWeb()
|
||||
dst_dir = sdir + '/web_conf/php'
|
||||
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):
|
||||
mw.execShell('mkdir -p ' + dst_dir_conf)
|
||||
|
||||
if not os.path.exists(dst_dir_status):
|
||||
mw.execShell('mkdir -p ' + dst_dir_status)
|
||||
|
||||
d_pathinfo = sdir + '/web_conf/php/pathinfo.conf'
|
||||
if not os.path.exists(d_pathinfo):
|
||||
s_pathinfo = getPluginDir() + '/conf/pathinfo.conf'
|
||||
shutil.copyfile(s_pathinfo, d_pathinfo)
|
||||
|
||||
info = getPluginDir() + '/info.json'
|
||||
content = mw.readFile(info)
|
||||
content = json.loads(content)
|
||||
versions = content['versions']
|
||||
tpl = getPluginDir() + '/conf/enable-php.conf'
|
||||
tpl_content = mw.readFile(tpl)
|
||||
for x in phpversions:
|
||||
dfile = sdir + '/web_conf/php/conf/enable-php-' + x + '.conf'
|
||||
if not os.path.exists(dfile):
|
||||
if x == '00':
|
||||
mw.writeFile(dfile, '')
|
||||
else:
|
||||
w_content = contentReplace(tpl_content, x)
|
||||
mw.writeFile(dfile, w_content)
|
||||
|
||||
# php-fpm status
|
||||
for version in phpversions:
|
||||
dfile = sdir + '/web_conf/php/status/phpfpm_status_' + 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 phpPrependFile(version):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ server
|
|||
root {$SERVER_PATH}/phpmyadmin;
|
||||
|
||||
#error_page 404 /404.html;
|
||||
include enable-php-{$PHP_VER}.conf;
|
||||
include {$PHP_CONF_PATH}/enable-php-{$PHP_VER}.conf;
|
||||
|
||||
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
|
||||
{
|
||||
|
|
|
|||
|
|
@ -98,8 +98,10 @@ def contentReplace(content):
|
|||
service_path = mw.getServerDir()
|
||||
php_ver = getCachePhpVer()
|
||||
# print php_ver
|
||||
php_conf_dir = mw.getServerDir() + '/web_conf/php/conf'
|
||||
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$PHP_CONF_PATH}', php_conf_dir)
|
||||
content = content.replace('{$PHP_VER}', php_ver)
|
||||
return content
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue