Merge pull request #3655 from Icinga/bugfix/setup-cli-webserver-config-fpm-enabled
Setup: Allow to enable FPM
This commit is contained in:
commit
ef470b3c1d
|
@ -99,6 +99,8 @@ class ConfigCommand extends Command
|
|||
* --root|--document-root=<directory> The directory from which the webserver will serve files
|
||||
* [/path/to/icingaweb2/public]
|
||||
*
|
||||
* --enable-fpm Enable FPM handler for Apache (Nginx is always enabled)
|
||||
*
|
||||
* --fpm-uri=<uri> Address or path where to pass requests to FPM [127.0.0.1:9000]
|
||||
*
|
||||
* --config=<directory> Path to Icinga Web 2's configuration files [/etc/icingaweb2]
|
||||
|
@ -149,6 +151,9 @@ class ConfigCommand extends Command
|
|||
'The argument --config expects a path to Icinga Web 2\'s configuration files'
|
||||
));
|
||||
}
|
||||
|
||||
$enableFpm = $this->params->shift('enable-fpm', $webserver->getEnableFpm());
|
||||
|
||||
$fpmUri = trim($this->params->get('fpm-uri', $webserver->getFpmUri()));
|
||||
if (empty($fpmUri)) {
|
||||
$this->fail($this->translate(
|
||||
|
@ -159,6 +164,7 @@ class ConfigCommand extends Command
|
|||
->setDocumentRoot($documentRoot)
|
||||
->setConfigDir($configDir)
|
||||
->setUrlPath($urlPath)
|
||||
->setEnableFpm($enableFpm)
|
||||
->setFpmUri($fpmUri);
|
||||
$config = $webserver->generate() . "\n";
|
||||
if (($file = $this->params->get('file')) !== null) {
|
||||
|
|
|
@ -39,6 +39,13 @@ abstract class Webserver
|
|||
*/
|
||||
protected $fpmUri;
|
||||
|
||||
/**
|
||||
* Enable to pass requests to FPM
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $enableFpm = false;
|
||||
|
||||
/**
|
||||
* Create instance by type name
|
||||
*
|
||||
|
@ -174,6 +181,30 @@ abstract class Webserver
|
|||
return $this->configDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether FPM is enabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getEnableFpm()
|
||||
{
|
||||
return $this->enableFpm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set FPM enabled
|
||||
*
|
||||
* @param bool $flag
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnableFpm($flag)
|
||||
{
|
||||
$this->enableFpm = (bool) $flag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the address or path where to pass requests to FPM
|
||||
*
|
||||
|
|
|
@ -10,10 +10,11 @@ use Icinga\Module\Setup\Webserver;
|
|||
*/
|
||||
class Apache extends Webserver
|
||||
{
|
||||
protected $fpmUri = 'fcgi://127.0.0.1:9000';
|
||||
protected $fpmUri = '127.0.0.1:9000';
|
||||
|
||||
protected function getTemplate()
|
||||
{
|
||||
if (! $this->enableFpm) {
|
||||
return <<<'EOD'
|
||||
Alias {urlPath} "{documentRoot}"
|
||||
|
||||
|
@ -22,7 +23,7 @@ Alias {urlPath} "{documentRoot}"
|
|||
# # Forward PHP requests to FPM
|
||||
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
||||
# <LocationMatch "^{urlPath}/(.*\.php)$">
|
||||
# ProxyPassMatch "fcgi://127.0.0.1:9000/{documentRoot}/$1"
|
||||
# ProxyPassMatch "fcgi://{fpmUri}/{documentRoot}/$1"
|
||||
# </LocationMatch>
|
||||
#</IfVersion>
|
||||
|
||||
|
@ -70,11 +71,72 @@ Alias {urlPath} "{documentRoot}"
|
|||
# # Forward PHP requests to FPM
|
||||
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
||||
# <FilesMatch "\.php$">
|
||||
# SetHandler "proxy:{fpmUri}"
|
||||
# SetHandler "proxy:fcgi://{fpmUri}"
|
||||
# ErrorDocument 503 {urlPath}/error_unavailable.html
|
||||
# </FilesMatch>
|
||||
# </IfVersion>
|
||||
</Directory>
|
||||
EOD;
|
||||
} else {
|
||||
return <<<'EOD'
|
||||
Alias {urlPath} "{documentRoot}"
|
||||
|
||||
<IfVersion < 2.4>
|
||||
# Forward PHP requests to FPM
|
||||
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
||||
<LocationMatch "^{urlPath}/(.*\.php)$">
|
||||
ProxyPassMatch "fcgi://{fpmUri}/{documentRoot}/$1"
|
||||
</LocationMatch>
|
||||
</IfVersion>
|
||||
|
||||
<Directory "{documentRoot}">
|
||||
Options SymLinksIfOwnerMatch
|
||||
AllowOverride None
|
||||
|
||||
DirectoryIndex index.php
|
||||
|
||||
<IfModule mod_authz_core.c>
|
||||
# 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 "{configDir}"
|
||||
|
||||
EnableSendfile Off
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteBase {urlPath}/
|
||||
RewriteCond %{REQUEST_FILENAME} -s [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -l [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
RewriteRule ^.*$ - [NC,L]
|
||||
RewriteRule ^.*$ index.php [NC,L]
|
||||
</IfModule>
|
||||
|
||||
<IfModule !mod_rewrite.c>
|
||||
DirectoryIndex error_norewrite.html
|
||||
ErrorDocument 404 {urlPath}/error_norewrite.html
|
||||
</IfModule>
|
||||
|
||||
<IfVersion >= 2.4>
|
||||
# Forward PHP requests to FPM
|
||||
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
||||
<FilesMatch "\.php$">
|
||||
SetHandler "proxy:fcgi://{fpmUri}"
|
||||
ErrorDocument 503 {urlPath}/error_unavailable.html
|
||||
</FilesMatch>
|
||||
</IfVersion>
|
||||
</Directory>
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ class Nginx extends Webserver
|
|||
{
|
||||
protected $fpmUri = '127.0.0.1:9000';
|
||||
|
||||
protected $enableFpm = true;
|
||||
|
||||
protected function getTemplate()
|
||||
{
|
||||
return <<<'EOD'
|
||||
|
|
Loading…
Reference in New Issue