Merge pull request #3284 from Icinga/feature/add-fpm-socket-commandline-switch-2862
Add fpm socket commandline switch when generating a webserver's configuration
This commit is contained in:
commit
9da67d9afe
|
@ -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]
|
||||||
*
|
*
|
||||||
|
* --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]
|
||||||
*
|
*
|
||||||
* --file=<filename> Write configuration to file [stdout]
|
* --file=<filename> Write configuration to file [stdout]
|
||||||
|
@ -115,7 +117,9 @@ class ConfigCommand extends Command
|
||||||
* icingacli setup config webserver apache \
|
* icingacli setup config webserver apache \
|
||||||
* --file=/etc/apache2/conf.d/icingaweb2.conf
|
* --file=/etc/apache2/conf.d/icingaweb2.conf
|
||||||
*
|
*
|
||||||
* icingacli setup config webserver nginx
|
* icingacli setup config webserver nginx \
|
||||||
|
* --root=/usr/share/icingaweb2/public \
|
||||||
|
* --fpm-uri=unix:/var/run/php5-fpm.sock
|
||||||
*/
|
*/
|
||||||
public function webserverAction()
|
public function webserverAction()
|
||||||
{
|
{
|
||||||
|
@ -145,10 +149,17 @@ 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'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
$fpmUri = trim($this->params->get('fpm-uri', $webserver->getFpmUri()));
|
||||||
|
if (empty($fpmUri)) {
|
||||||
|
$this->fail($this->translate(
|
||||||
|
'The argument --fpm-uri expects an address or path where to pass requests to FPM'
|
||||||
|
));
|
||||||
|
}
|
||||||
$webserver
|
$webserver
|
||||||
->setDocumentRoot($documentRoot)
|
->setDocumentRoot($documentRoot)
|
||||||
->setConfigDir($configDir)
|
->setConfigDir($configDir)
|
||||||
->setUrlPath($urlPath);
|
->setUrlPath($urlPath)
|
||||||
|
->setFpmUri($fpmUri);
|
||||||
$config = $webserver->generate() . "\n";
|
$config = $webserver->generate() . "\n";
|
||||||
if (($file = $this->params->get('file')) !== null) {
|
if (($file = $this->params->get('file')) !== null) {
|
||||||
if (file_exists($file) === true) {
|
if (file_exists($file) === true) {
|
||||||
|
|
|
@ -32,6 +32,13 @@ abstract class Webserver
|
||||||
*/
|
*/
|
||||||
protected $configDir;
|
protected $configDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Address or path where to pass requests to FPM
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $fpmUri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance by type name
|
* Create instance by type name
|
||||||
*
|
*
|
||||||
|
@ -63,11 +70,13 @@ abstract class Webserver
|
||||||
'{urlPath}',
|
'{urlPath}',
|
||||||
'{documentRoot}',
|
'{documentRoot}',
|
||||||
'{configDir}',
|
'{configDir}',
|
||||||
|
'{fpmUri}'
|
||||||
);
|
);
|
||||||
$replaceTokens = array(
|
$replaceTokens = array(
|
||||||
$this->getUrlPath(),
|
$this->getUrlPath(),
|
||||||
$this->getDocumentRoot(),
|
$this->getDocumentRoot(),
|
||||||
$this->getConfigDir()
|
$this->getConfigDir(),
|
||||||
|
$this->getFpmUri()
|
||||||
);
|
);
|
||||||
$template = str_replace($searchTokens, $replaceTokens, $template);
|
$template = str_replace($searchTokens, $replaceTokens, $template);
|
||||||
return $template;
|
return $template;
|
||||||
|
@ -164,4 +173,28 @@ abstract class Webserver
|
||||||
}
|
}
|
||||||
return $this->configDir;
|
return $this->configDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the address or path where to pass requests to FPM
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFpmUri()
|
||||||
|
{
|
||||||
|
return $this->fpmUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the address or path where to pass requests to FPM
|
||||||
|
*
|
||||||
|
* @param string $uri
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFpmUri($uri)
|
||||||
|
{
|
||||||
|
$this->fpmUri = (string) $uri;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ use Icinga\Module\Setup\Webserver;
|
||||||
*/
|
*/
|
||||||
class Apache extends Webserver
|
class Apache extends Webserver
|
||||||
{
|
{
|
||||||
|
protected $fpmUri = 'fgci://127.0.0.1:9000';
|
||||||
|
|
||||||
protected function getTemplate()
|
protected function getTemplate()
|
||||||
{
|
{
|
||||||
return <<<'EOD'
|
return <<<'EOD'
|
||||||
|
@ -68,7 +70,7 @@ 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:fcgi://127.0.0.1:9000"
|
# SetHandler "proxy:{fpmUri}"
|
||||||
# ErrorDocument 503 {urlPath}/error_unavailable.html
|
# ErrorDocument 503 {urlPath}/error_unavailable.html
|
||||||
# </FilesMatch>
|
# </FilesMatch>
|
||||||
# </IfVersion>
|
# </IfVersion>
|
||||||
|
|
|
@ -10,17 +10,13 @@ use Icinga\Module\Setup\Webserver;
|
||||||
*/
|
*/
|
||||||
class Nginx extends Webserver
|
class Nginx extends Webserver
|
||||||
{
|
{
|
||||||
/**
|
protected $fpmUri = '127.0.0.1:9000';
|
||||||
* Specific template
|
|
||||||
*
|
|
||||||
* @return array|string
|
|
||||||
*/
|
|
||||||
protected function getTemplate()
|
protected function getTemplate()
|
||||||
{
|
{
|
||||||
return <<<'EOD'
|
return <<<'EOD'
|
||||||
location ~ ^{urlPath}/index\.php(.*)$ {
|
location ~ ^{urlPath}/index\.php(.*)$ {
|
||||||
# fastcgi_pass 127.0.0.1:9000;
|
fastcgi_pass {fpmUri};
|
||||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_param SCRIPT_FILENAME {documentRoot}/index.php;
|
fastcgi_param SCRIPT_FILENAME {documentRoot}/index.php;
|
||||||
|
|
Loading…
Reference in New Issue