diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index 29f5f967166..e107ed34817 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -101,7 +101,7 @@ protected function initGeneralSettings(): void { $this->initialState->provideInitialState('default_group_notification', (int) $this->serverConfig->getAppValue('spreed', 'default_group_notification', Participant::NOTIFY_MENTION)); $this->initialState->provideInitialState('conversations_files', (int) $this->serverConfig->getAppValue('spreed', 'conversations_files', '1')); $this->initialState->provideInitialState('conversations_files_public_shares', (int) $this->serverConfig->getAppValue('spreed', 'conversations_files_public_shares', '1')); - $this->initialState->provideInitialState('valid_apache_php_configuration', (int) $this->validApachePHPConfiguration()); + $this->initialState->provideInitialState('valid_apache_php_configuration', $this->validApachePHPConfiguration()); } protected function initAllowedGroups(): void { @@ -502,12 +502,20 @@ protected function getGroupDetailsArray(array $gids, string $configKey): array { return $groups; } - protected function validApachePHPConfiguration(): bool { + protected function validApachePHPConfiguration(): string { + if (!function_exists('exec')) { + return 'unknown'; + } + $output = []; - @exec('apachectl -M | grep mpm', $output, $returnCode); + try { + @exec('apachectl -M | grep mpm', $output, $returnCode); + } catch (\Throwable $e) { + return 'unknown'; + } if ($returnCode > 0) { - return true; + return 'unknown'; } $apacheModule = implode("\n", $output); @@ -515,11 +523,11 @@ protected function validApachePHPConfiguration(): bool { if ($usingFPM) { // Needs to use mpm_event - return strpos($apacheModule, 'mpm_event') !== false; + return strpos($apacheModule, 'mpm_event') !== false ? '' : 'invalid'; } // Needs to use mpm_prefork - return strpos($apacheModule, 'mpm_prefork') !== false; + return strpos($apacheModule, 'mpm_prefork') !== false ? '' : 'invalid'; } /** diff --git a/src/components/AdminSettings/WebServerSetupChecks.vue b/src/components/AdminSettings/WebServerSetupChecks.vue index 79f860c466d..075e507a79f 100644 --- a/src/components/AdminSettings/WebServerSetupChecks.vue +++ b/src/components/AdminSettings/WebServerSetupChecks.vue @@ -77,7 +77,7 @@ export default { data() { return { backgroundBlurLoaded: undefined, - validApachePHPConfiguration: true, + validApachePHPConfiguration: '', } }, @@ -115,12 +115,18 @@ export default { }, apacheWarning() { - return t('spreed', 'It seems that the PHP and Apache configuration is not compatible. Please note that PHP can only be used with the MPM_PREFORK module and PHP-FPM can only be used with the MPM_EVENT module.') + if (this.validApachePHPConfiguration === 'invalid') { + return t('spreed', 'It seems that the PHP and Apache configuration is not compatible. Please note that PHP can only be used with the MPM_PREFORK module and PHP-FPM can only be used with the MPM_EVENT module.') + } + if (this.validApachePHPConfiguration === 'unknown') { + return t('spreed', 'Could not detect the PHP and Apache configuration because exec is disabled or apachectl is not working as expected. Please note that PHP can only be used with the MPM_PREFORK module and PHP-FPM can only be used with the MPM_EVENT module.') + } + return '' }, }, mounted() { - this.validApachePHPConfiguration = parseInt(loadState('spreed', 'valid_apache_php_configuration')) === 1 + this.validApachePHPConfiguration = loadState('spreed', 'valid_apache_php_configuration') }, beforeMount() {