From ad63ca0c8ba8420d17c49f4b6b73c98a6ee65390 Mon Sep 17 00:00:00 2001 From: "Matt (IPv4) Cowley" Date: Thu, 4 Feb 2021 19:29:32 +0000 Subject: [PATCH] Support custom PHP server values (#218) * Add the logic for custom php paths * Add the i18n strings * Fix some visual things --- src/nginxconfig/generators/conf/nginx.conf.js | 7 +- .../generators/conf/php_fastcgi.conf.js | 7 +- .../i18n/en/templates/global_sections/php.js | 3 +- .../i18n/fr/templates/global_sections/php.js | 1 + .../pt-br/templates/global_sections/php.js | 3 +- .../zh-cn/templates/global_sections/php.js | 3 +- .../zh-tw/templates/global_sections/php.js | 3 +- .../templates/global_sections/php.vue | 78 +++++++++++++++---- src/nginxconfig/util/php_path.js | 31 ++++++++ 9 files changed, 112 insertions(+), 24 deletions(-) create mode 100644 src/nginxconfig/util/php_path.js diff --git a/src/nginxconfig/generators/conf/nginx.conf.js b/src/nginxconfig/generators/conf/nginx.conf.js index 5a554c4..c23710a 100644 --- a/src/nginxconfig/generators/conf/nginx.conf.js +++ b/src/nginxconfig/generators/conf/nginx.conf.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2021 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -27,6 +27,7 @@ THE SOFTWARE. import sslProfiles from '../../util/ssl_profiles'; import websiteConf from './website.conf'; import shareQuery from '../../util/share_query'; +import phpPath from '../../util/php_path'; export default (domains, global) => { const config = {}; @@ -53,8 +54,8 @@ export default (domains, global) => { if (global.php.phpBackupServer.computed) config.http.push(['upstream php', { server: [ - `${global.php.phpServer.computed[0] === '/' ? 'unix:' : ''}${global.php.phpServer.computed}`, - `${global.php.phpBackupServer.computed[0] === '/' ? 'unix:' : ''}${global.php.phpBackupServer.computed} backup`, + phpPath(global), + `${phpPath(global, true)} backup`, ], }]); diff --git a/src/nginxconfig/generators/conf/php_fastcgi.conf.js b/src/nginxconfig/generators/conf/php_fastcgi.conf.js index d1f8919..f7f1d17 100644 --- a/src/nginxconfig/generators/conf/php_fastcgi.conf.js +++ b/src/nginxconfig/generators/conf/php_fastcgi.conf.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2021 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -24,6 +24,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +import phpPath from '../../util/php_path'; + export default (domains, global) => { const legacyRouting = domains.some(d => d.routing.legacyPhpRouting.computed); const config = {}; @@ -42,8 +44,7 @@ export default (domains, global) => { config['# fastcgi settings'] = ''; config.fastcgi_pass = domains.some(d => d.php.php.computed) && global.php.phpBackupServer.computed !== '' - ? 'php' - : ((global.php.phpServer.computed[0] === '/' ? 'unix:' : '') + global.php.phpServer.computed); + ? 'php' : phpPath(global); config.fastcgi_index = 'index.php'; config.fastcgi_buffers = '8 16k'; config.fastcgi_buffer_size = '32k'; diff --git a/src/nginxconfig/i18n/en/templates/global_sections/php.js b/src/nginxconfig/i18n/en/templates/global_sections/php.js index baf9542..176a123 100644 --- a/src/nginxconfig/i18n/en/templates/global_sections/php.js +++ b/src/nginxconfig/i18n/en/templates/global_sections/php.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2021 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -40,5 +40,6 @@ export default { php74Socket: '7.4 socket', php80Socket: '8.0 socket', phpSocket: 'PHP socket', + custom: 'Custom', disabled: 'Disabled', }; diff --git a/src/nginxconfig/i18n/fr/templates/global_sections/php.js b/src/nginxconfig/i18n/fr/templates/global_sections/php.js index b04ebb8..c006f4f 100644 --- a/src/nginxconfig/i18n/fr/templates/global_sections/php.js +++ b/src/nginxconfig/i18n/fr/templates/global_sections/php.js @@ -40,5 +40,6 @@ export default { php74Socket: 'Socket 7.4', php80Socket: 'Socket 8.0', phpSocket: 'Socket PHP', + custom: 'Custom', // TODO: translate disabled: 'Désactivé', }; diff --git a/src/nginxconfig/i18n/pt-br/templates/global_sections/php.js b/src/nginxconfig/i18n/pt-br/templates/global_sections/php.js index 067ae90..c8abcb4 100644 --- a/src/nginxconfig/i18n/pt-br/templates/global_sections/php.js +++ b/src/nginxconfig/i18n/pt-br/templates/global_sections/php.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2021 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -40,5 +40,6 @@ export default { php74Socket: 'Socket 7.4', php80Socket: 'Socket 8.0', phpSocket: 'Socket PHP', + custom: 'Custom', // TODO: translate disabled: 'Desabilitado', }; diff --git a/src/nginxconfig/i18n/zh-cn/templates/global_sections/php.js b/src/nginxconfig/i18n/zh-cn/templates/global_sections/php.js index 6fe1c9e..1780e41 100644 --- a/src/nginxconfig/i18n/zh-cn/templates/global_sections/php.js +++ b/src/nginxconfig/i18n/zh-cn/templates/global_sections/php.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2021 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -40,5 +40,6 @@ export default { php74Socket: '7.4 socket', php80Socket: '8.0 socket', phpSocket: 'PHP socket', + custom: 'Custom', // TODO: translate disabled: '禁用', }; diff --git a/src/nginxconfig/i18n/zh-tw/templates/global_sections/php.js b/src/nginxconfig/i18n/zh-tw/templates/global_sections/php.js index afe0681..f71f5d3 100644 --- a/src/nginxconfig/i18n/zh-tw/templates/global_sections/php.js +++ b/src/nginxconfig/i18n/zh-tw/templates/global_sections/php.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2021 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -40,5 +40,6 @@ export default { php74Socket: '7.4 socket', php80Socket: '8.0 socket', phpSocket: 'PHP socket', + custom: 'Custom', // TODO: translate disabled: '禁用', }; diff --git a/src/nginxconfig/templates/global_sections/php.vue b/src/nginxconfig/templates/global_sections/php.vue index 68a5e9a..99a2758 100644 --- a/src/nginxconfig/templates/global_sections/php.vue +++ b/src/nginxconfig/templates/global_sections/php.vue @@ -1,5 +1,5 @@