php配置改造

pull/522/head
Mr Chen 1 year ago
parent 86e3796524
commit 7524798385
  1. 2
      plugins/php/conf/enable-php-upstream.conf
  2. 9
      plugins/php/conf/enable-php.bak.conf
  3. 3
      plugins/php/conf/enable-php.conf
  4. 50
      plugins/php/index.py

@ -1,4 +1,4 @@
upstream UP-PHP{$PHP_VERSION} {
upstream UPSTREAM-PHP{$PHP_VERSION} {
server unix:/tmp/php-cgi-{$PHP_VERSION}.sock;
server unix:/tmp/php-cgi-{$PHP_VERSION}.backup.sock;
}

@ -0,0 +1,9 @@
set $PHP_ENV 1;
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-{$PHP_VERSION}.sock;
fastcgi_index index.php;
include fastcgi.conf;
include {$SERVER_PATH}/web_conf/php/pathinfo.conf;
}

@ -2,7 +2,8 @@ set $PHP_ENV 1;
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-{$PHP_VERSION}.sock;
#fastcgi_pass unix:/tmp/php-cgi-{$PHP_VERSION}.sock;
fastcgi_pass UPSTREAM-PHP{$PHP_VERSION};
fastcgi_index index.php;
include fastcgi.conf;
include {$SERVER_PATH}/web_conf/php/pathinfo.conf;

@ -162,17 +162,21 @@ def makeOpenrestyConf():
sdir = mw.getServerDir()
dst_dir = sdir + '/web_conf/php'
dst_dir_conf = sdir + '/web_conf/php/conf'
if not os.path.exists(dst_dir):
mw.execShell('mkdir -p ' + dst_dir)
dst_dir_conf = sdir + '/web_conf/php/conf'
if not os.path.exists(dst_dir_conf):
mw.execShell('mkdir -p ' + dst_dir_conf)
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)
dst_dir_upstream = sdir + '/web_conf/php/upstream'
if not os.path.exists(dst_dir_upstream):
mw.execShell('mkdir -p ' + dst_dir_upstream)
dst_pathinfo = sdir + '/web_conf/php/pathinfo.conf'
if not os.path.exists(dst_pathinfo):
src_pathinfo = getPluginDir() + '/conf/pathinfo.conf'
shutil.copyfile(src_pathinfo, dst_pathinfo)
info = getPluginDir() + '/info.json'
content = mw.readFile(info)
@ -184,19 +188,31 @@ def makeOpenrestyConf():
dfile = sdir + '/web_conf/php/conf/enable-php-' + x + '.conf'
if not os.path.exists(dfile):
if x == '00':
mw.writeFile(dfile, 'set $PHP_ENV 0;')
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)
content = contentReplace(tpl_content, x)
mw.writeFile(dfile, content)
upstream_tpl = getPluginDir() + '/conf/enable-php-upstream.conf'
upstream_tpl_content = mw.readFile(upstream_tpl)
for x in phpversions:
dfile = sdir + '/web_conf/php/upstream/enable-php-' + x + '.conf'
if not os.path.exists(dfile):
if x == '00':
mw.writeFile(dfile, '')
else:
content = contentReplace(upstream_tpl_content, x)
mw.writeFile(dfile, content)
vhost_dir = mw.getServerDir() + '/web_conf/nginx/vhost'
write_php_upstream_conf = mw.getServerDir()+'/web_conf/php/upstream/*.conf;'
if not os.path.exists(vhost_dir):
mw.execShell('mkdir -p ' + vhost_dir)
vhost_php_upstream = vhost_dir+'/0.php_upstream.conf'
if not os.path.exists(vhost_php_upstream):
mw.writeFile(vhost_php_upstream,'include '+write_php_upstream_conf)
def phpPrependFile(version):

Loading…
Cancel
Save