diff --git a/class/core/site_api.py b/class/core/site_api.py index 109e7a5e9..c2a646885 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -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) diff --git a/data/tpl/nginx.conf b/data/tpl/nginx.conf index ac97996bd..246831f69 100755 --- a/data/tpl/nginx.conf +++ b/data/tpl/nginx.conf @@ -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 diff --git a/plugins/openresty/conf/nginx.conf b/plugins/openresty/conf/nginx.conf index 8ed83ed10..c5f539921 100644 --- a/plugins/openresty/conf/nginx.conf +++ b/plugins/openresty/conf/nginx.conf @@ -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; } diff --git a/plugins/php/conf/enable-php.conf b/plugins/php/conf/enable-php.conf index 9f22fb939..d9712e0e3 100644 --- a/plugins/php/conf/enable-php.conf +++ b/plugins/php/conf/enable-php.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; } \ No newline at end of file diff --git a/plugins/php/index.py b/plugins/php/index.py index 5a0758c00..10ab15330 100755 --- a/plugins/php/index.py +++ b/plugins/php/index.py @@ -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): diff --git a/plugins/phpmyadmin/conf/phpmyadmin.conf b/plugins/phpmyadmin/conf/phpmyadmin.conf index b1e968337..4f32e6c28 100755 --- a/plugins/phpmyadmin/conf/phpmyadmin.conf +++ b/plugins/phpmyadmin/conf/phpmyadmin.conf @@ -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)$ { diff --git a/plugins/phpmyadmin/index.py b/plugins/phpmyadmin/index.py index 9483645f4..43e037b0f 100755 --- a/plugins/phpmyadmin/index.py +++ b/plugins/phpmyadmin/index.py @@ -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