From f07cbcc107f0934500903d37772118ad7e8796d3 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Fri, 7 Nov 2014 10:34:53 +0100 Subject: [PATCH] Setup/Webserver: Consolidate apache config Add configDir to replace tokens. refs #6120 --- application/clicommands/SetupCommand.php | 6 ++- .../Icinga/Web/Setup/Webserver/Apache2.php | 39 +++++++++++++++---- .../Icinga/Web/Setup/Webserver/Apache24.php | 29 -------------- .../Icinga/Web/Setup/Webserver/Webserver.php | 6 ++- 4 files changed, 39 insertions(+), 41 deletions(-) delete mode 100644 library/Icinga/Web/Setup/Webserver/Apache24.php diff --git a/application/clicommands/SetupCommand.php b/application/clicommands/SetupCommand.php index caa07ae1d..5fbe309c8 100644 --- a/application/clicommands/SetupCommand.php +++ b/application/clicommands/SetupCommand.php @@ -128,7 +128,7 @@ class SetupCommand extends Command * * USAGE: * - * icingacli setup webserver [options] + * icingacli setup webserver [options] * * OPTIONS: * @@ -141,11 +141,13 @@ class SetupCommand extends Command * * EXAMPLES: * - * icingacli setup webserver apache24 + * icingacli setup webserver apache2 * * icingacli setup webserver apache2 --path /icingaweb --publicPath /usr/share/icingaweb/public * * icingacli setup webserver apache2 --file /etc/apache2/conf.d/icingaweb.conf + * + * icingacli setup webserver nginx */ public function webserverAction() { diff --git a/library/Icinga/Web/Setup/Webserver/Apache2.php b/library/Icinga/Web/Setup/Webserver/Apache2.php index 846dc0a96..767e9a882 100644 --- a/library/Icinga/Web/Setup/Webserver/Apache2.php +++ b/library/Icinga/Web/Setup/Webserver/Apache2.php @@ -15,14 +15,37 @@ class Apache2 extends Webserver protected function getTemplate() { return <<<'EOD' -Alias {webPath} {publicPath} - - Options -Indexes - AllowOverride All - Order allow,deny - Allow from all - EnableSendfile Off - +Alias {webPath} "{publicPath}" + + + Options SymLinksIfOwnerMatch + AllowOverride None + + + # Apache 2.4 + + Require all granted + + + + + # Apache 2.2 + Order allow,deny + Allow from all + + + SetEnv ICINGAWEB_CONFIGDIR /etc/icingaweb/ + + EnableSendfile Off + + RewriteEngine on + RewriteBase {webPath}/ + RewriteCond %{REQUEST_FILENAME} -s [OR] + RewriteCond %{REQUEST_FILENAME} -l [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^.*$ - [NC,L] + RewriteRule ^.*$ index.php [NC,L] + EOD; } diff --git a/library/Icinga/Web/Setup/Webserver/Apache24.php b/library/Icinga/Web/Setup/Webserver/Apache24.php deleted file mode 100644 index c9992e794..000000000 --- a/library/Icinga/Web/Setup/Webserver/Apache24.php +++ /dev/null @@ -1,29 +0,0 @@ - - Options -Indexes - AllowOverride All - Require all granted - EnableSendfile Off - -EOD; - } -} diff --git a/library/Icinga/Web/Setup/Webserver/Webserver.php b/library/Icinga/Web/Setup/Webserver/Webserver.php index 56ade8467..47ffc4a10 100644 --- a/library/Icinga/Web/Setup/Webserver/Webserver.php +++ b/library/Icinga/Web/Setup/Webserver/Webserver.php @@ -69,11 +69,13 @@ abstract class Webserver $searchTokens = array( '{webPath}', - '{publicPath}' + '{publicPath}', + '{configPath}', ); $replaceTokens = array( $this->getWebPath(), - $this->getPublicPath() + $this->getPublicPath(), + $this->getApp()->getConfigDir() ); $template = str_replace($searchTokens, $replaceTokens, $template); return $template;