Setup/Webserver: Consolidate apache config

Add configDir to replace tokens.

refs #6120
This commit is contained in:
Marius Hein 2014-11-07 10:34:53 +01:00
parent ddf6bb4472
commit f07cbcc107
4 changed files with 39 additions and 41 deletions

View File

@ -128,7 +128,7 @@ class SetupCommand extends Command
* *
* USAGE: * USAGE:
* *
* icingacli setup webserver <apache2|apache24|nginx> [options] * icingacli setup webserver <apache2|nginx> [options]
* *
* OPTIONS: * OPTIONS:
* *
@ -141,11 +141,13 @@ class SetupCommand extends Command
* *
* EXAMPLES: * EXAMPLES:
* *
* icingacli setup webserver apache24 * icingacli setup webserver apache2
* *
* icingacli setup webserver apache2 --path /icingaweb --publicPath /usr/share/icingaweb/public * 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 apache2 --file /etc/apache2/conf.d/icingaweb.conf
*
* icingacli setup webserver nginx
*/ */
public function webserverAction() public function webserverAction()
{ {

View File

@ -15,14 +15,37 @@ class Apache2 extends Webserver
protected function getTemplate() protected function getTemplate()
{ {
return <<<'EOD' return <<<'EOD'
Alias {webPath} {publicPath} Alias {webPath} "{publicPath}"
<directory {publicPath}>
Options -Indexes <Directory "{publicPath}">
AllowOverride All Options SymLinksIfOwnerMatch
Order allow,deny AllowOverride None
Allow from all
EnableSendfile Off <IfModule mod_authz_core.c>
</directory> # Apache 2.4
<RequireAll>
Require all granted
</RequireAll>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order allow,deny
Allow from all
</IfModule>
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]
</Directory>
EOD; EOD;
} }

View File

@ -1,29 +0,0 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
namespace Icinga\Web\Setup\Webserver;
/**
* Generate apache2.4 configuration
*/
class Apache24 extends Webserver
{
/**
* Use default template and change granted syntax for 2.4
*
* @return array
*/
protected function getTemplate()
{
return <<<'EOD'
Alias {webPath} {publicPath}
<directory {publicPath}>
Options -Indexes
AllowOverride All
Require all granted
EnableSendfile Off
</directory>
EOD;
}
}

View File

@ -69,11 +69,13 @@ abstract class Webserver
$searchTokens = array( $searchTokens = array(
'{webPath}', '{webPath}',
'{publicPath}' '{publicPath}',
'{configPath}',
); );
$replaceTokens = array( $replaceTokens = array(
$this->getWebPath(), $this->getWebPath(),
$this->getPublicPath() $this->getPublicPath(),
$this->getApp()->getConfigDir()
); );
$template = str_replace($searchTokens, $replaceTokens, $template); $template = str_replace($searchTokens, $replaceTokens, $template);
return $template; return $template;