mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-06-28 01:24:24 +02:00
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
|
* --root|--document-root=<directory> The directory from which the webserver will serve files
|
||||||
* [/path/to/icingaweb2/public]
|
* [/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]
|
* --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]
|
* --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'
|
'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()));
|
$fpmUri = trim($this->params->get('fpm-uri', $webserver->getFpmUri()));
|
||||||
if (empty($fpmUri)) {
|
if (empty($fpmUri)) {
|
||||||
$this->fail($this->translate(
|
$this->fail($this->translate(
|
||||||
@ -159,6 +164,7 @@ class ConfigCommand extends Command
|
|||||||
->setDocumentRoot($documentRoot)
|
->setDocumentRoot($documentRoot)
|
||||||
->setConfigDir($configDir)
|
->setConfigDir($configDir)
|
||||||
->setUrlPath($urlPath)
|
->setUrlPath($urlPath)
|
||||||
|
->setEnableFpm($enableFpm)
|
||||||
->setFpmUri($fpmUri);
|
->setFpmUri($fpmUri);
|
||||||
$config = $webserver->generate() . "\n";
|
$config = $webserver->generate() . "\n";
|
||||||
if (($file = $this->params->get('file')) !== null) {
|
if (($file = $this->params->get('file')) !== null) {
|
||||||
|
@ -39,6 +39,13 @@ abstract class Webserver
|
|||||||
*/
|
*/
|
||||||
protected $fpmUri;
|
protected $fpmUri;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable to pass requests to FPM
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $enableFpm = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance by type name
|
* Create instance by type name
|
||||||
*
|
*
|
||||||
@ -174,6 +181,30 @@ abstract class Webserver
|
|||||||
return $this->configDir;
|
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
|
* Get the address or path where to pass requests to FPM
|
||||||
*
|
*
|
||||||
|
@ -10,10 +10,11 @@ use Icinga\Module\Setup\Webserver;
|
|||||||
*/
|
*/
|
||||||
class Apache extends Webserver
|
class Apache extends Webserver
|
||||||
{
|
{
|
||||||
protected $fpmUri = 'fcgi://127.0.0.1:9000';
|
protected $fpmUri = '127.0.0.1:9000';
|
||||||
|
|
||||||
protected function getTemplate()
|
protected function getTemplate()
|
||||||
{
|
{
|
||||||
|
if (! $this->enableFpm) {
|
||||||
return <<<'EOD'
|
return <<<'EOD'
|
||||||
Alias {urlPath} "{documentRoot}"
|
Alias {urlPath} "{documentRoot}"
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ Alias {urlPath} "{documentRoot}"
|
|||||||
# # Forward PHP requests to FPM
|
# # Forward PHP requests to FPM
|
||||||
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
||||||
# <LocationMatch "^{urlPath}/(.*\.php)$">
|
# <LocationMatch "^{urlPath}/(.*\.php)$">
|
||||||
# ProxyPassMatch "fcgi://127.0.0.1:9000/{documentRoot}/$1"
|
# ProxyPassMatch "fcgi://{fpmUri}/{documentRoot}/$1"
|
||||||
# </LocationMatch>
|
# </LocationMatch>
|
||||||
#</IfVersion>
|
#</IfVersion>
|
||||||
|
|
||||||
@ -70,11 +71,72 @@ Alias {urlPath} "{documentRoot}"
|
|||||||
# # Forward PHP requests to FPM
|
# # Forward PHP requests to FPM
|
||||||
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
||||||
# <FilesMatch "\.php$">
|
# <FilesMatch "\.php$">
|
||||||
# SetHandler "proxy:{fpmUri}"
|
# SetHandler "proxy:fcgi://{fpmUri}"
|
||||||
# ErrorDocument 503 {urlPath}/error_unavailable.html
|
# ErrorDocument 503 {urlPath}/error_unavailable.html
|
||||||
# </FilesMatch>
|
# </FilesMatch>
|
||||||
# </IfVersion>
|
# </IfVersion>
|
||||||
</Directory>
|
</Directory>
|
||||||
EOD;
|
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 $fpmUri = '127.0.0.1:9000';
|
||||||
|
|
||||||
|
protected $enableFpm = true;
|
||||||
|
|
||||||
protected function getTemplate()
|
protected function getTemplate()
|
||||||
{
|
{
|
||||||
return <<<'EOD'
|
return <<<'EOD'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user