Browse Source

Make apache configuration check less error prone

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/8283/head
Joas Schilling 3 years ago
parent
commit
3d66523497
No known key found for this signature in database GPG Key ID: 74434EFE0D2E2205
  1. 20
      lib/Settings/Admin/AdminSettings.php
  2. 12
      src/components/AdminSettings/WebServerSetupChecks.vue

20
lib/Settings/Admin/AdminSettings.php

@ -101,7 +101,7 @@ class AdminSettings implements ISettings {
$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 @@ class AdminSettings implements ISettings {
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 @@ class AdminSettings implements ISettings {
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';
}
/**

12
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() {

Loading…
Cancel
Save