mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
parent
0d4ed40cb2
commit
8594dc068a
@ -100,15 +100,14 @@ class ConfigCommand extends Command
|
|||||||
} catch (ProgrammingError $e) {
|
} catch (ProgrammingError $e) {
|
||||||
$this->fail($this->translate('Unknown type') . ': ' . $type);
|
$this->fail($this->translate('Unknown type') . ': ' . $type);
|
||||||
}
|
}
|
||||||
$webserver->setApp($this->app);
|
|
||||||
if (($path = $this->params->get('path', '/icingaweb')) === null) {
|
if (($path = $this->params->get('path', '/icingaweb')) === null) {
|
||||||
$this->fail($this->translate('argument --path is mandatory.'));
|
$this->fail($this->translate('argument --path is mandatory.'));
|
||||||
}
|
}
|
||||||
if (($publicPath = $this->params->get('publicPath', $webserver->getPublicPath())) === null) {
|
if (($documentRoot = $this->params->get('documentRoot', $webserver->getDocumentRoot())) === null) {
|
||||||
$this->fail($this->translate('argument --publicPath is mandatory.'));
|
$this->fail($this->translate('argument --publicPath is mandatory.'));
|
||||||
}
|
}
|
||||||
$webserver->setWebPath($path);
|
$webserver->setWebPath($path);
|
||||||
$webserver->setPublicPath($publicPath);
|
$webserver->setDocumentRoot($documentRoot);
|
||||||
$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) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Setup;
|
namespace Icinga\Module\Setup;
|
||||||
|
|
||||||
use Icinga\Application\ApplicationBootstrap;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,6 +12,13 @@ use Icinga\Exception\ProgrammingError;
|
|||||||
*/
|
*/
|
||||||
abstract class Webserver
|
abstract class Webserver
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Document root
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $documentRoot;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web path
|
* Web path
|
||||||
*
|
*
|
||||||
@ -19,20 +26,6 @@ abstract class Webserver
|
|||||||
*/
|
*/
|
||||||
protected $webPath;
|
protected $webPath;
|
||||||
|
|
||||||
/**
|
|
||||||
* System path to public documents
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $publicPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Application
|
|
||||||
*
|
|
||||||
* @var ApplicationBootstrap
|
|
||||||
*/
|
|
||||||
protected $app;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance by type name
|
* Create instance by type name
|
||||||
*
|
*
|
||||||
@ -62,13 +55,13 @@ abstract class Webserver
|
|||||||
|
|
||||||
$searchTokens = array(
|
$searchTokens = array(
|
||||||
'{webPath}',
|
'{webPath}',
|
||||||
'{publicPath}',
|
'{documentRoot}',
|
||||||
'{configPath}',
|
'{configPath}',
|
||||||
);
|
);
|
||||||
$replaceTokens = array(
|
$replaceTokens = array(
|
||||||
$this->getWebPath(),
|
$this->getWebPath(),
|
||||||
$this->getPublicPath(),
|
$this->getDocumentRoot(),
|
||||||
$this->getApp()->getConfigDir()
|
Icinga::app()->getConfigDir()
|
||||||
);
|
);
|
||||||
$template = str_replace($searchTokens, $replaceTokens, $template);
|
$template = str_replace($searchTokens, $replaceTokens, $template);
|
||||||
return $template;
|
return $template;
|
||||||
@ -102,58 +95,38 @@ abstract class Webserver
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $publicPath
|
* Set the document root
|
||||||
|
*
|
||||||
|
* @param string $documentRoot
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setPublicPath($publicPath)
|
public function setDocumentRoot($documentRoot)
|
||||||
{
|
{
|
||||||
$this->publicPath = $publicPath;
|
$this->documentRoot = (string) $documentRoot;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect public root
|
* Detect the document root
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function detectPublicPath()
|
public function detectDocumentRoot()
|
||||||
{
|
{
|
||||||
$applicationPath = $this->getApp()->getApplicationDir();
|
return Icinga::app()->getBaseDir('public');
|
||||||
$applicationPath = dirname($applicationPath) . DIRECTORY_SEPARATOR . 'public';
|
|
||||||
if (is_dir($applicationPath) === true) {
|
|
||||||
return $applicationPath;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for public root
|
* Get the document root
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPublicPath()
|
public function getDocumentRoot()
|
||||||
{
|
{
|
||||||
if ($this->publicPath === null) {
|
if ($this->documentRoot === null) {
|
||||||
$this->publicPath = $this->detectPublicPath();
|
$this->documentRoot = $this->detectDocumentRoot();
|
||||||
}
|
}
|
||||||
return $this->publicPath;
|
return $this->documentRoot;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter for application bootstrap
|
|
||||||
*
|
|
||||||
* @param ApplicationBootstrap $app
|
|
||||||
*/
|
|
||||||
public function setApp(ApplicationBootstrap $app)
|
|
||||||
{
|
|
||||||
$this->app = $app;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter for application bootstrap
|
|
||||||
*
|
|
||||||
* @return ApplicationBootstrap
|
|
||||||
*/
|
|
||||||
public function getApp()
|
|
||||||
{
|
|
||||||
return $this->app;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ class Apache extends Webserver
|
|||||||
protected function getTemplate()
|
protected function getTemplate()
|
||||||
{
|
{
|
||||||
return <<<'EOD'
|
return <<<'EOD'
|
||||||
Alias {webPath} "{publicPath}"
|
Alias {webPath} "{documentRoot}"
|
||||||
|
|
||||||
<Directory "{publicPath}">
|
<Directory "{documentRoot}">
|
||||||
Options SymLinksIfOwnerMatch
|
Options SymLinksIfOwnerMatch
|
||||||
AllowOverride None
|
AllowOverride None
|
||||||
|
|
||||||
@ -54,7 +54,6 @@ Alias {webPath} "{publicPath}"
|
|||||||
DirectoryIndex error_norewrite.html
|
DirectoryIndex error_norewrite.html
|
||||||
ErrorDocument 404 /error_norewrite.html
|
ErrorDocument 404 /error_norewrite.html
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
||||||
</Directory>
|
</Directory>
|
||||||
EOD;
|
EOD;
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ location ~ ^{webPath}/index\.php(.*)$ {
|
|||||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
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 {publicPath}/index.php;
|
fastcgi_param SCRIPT_FILENAME {documentRoot}/index.php;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ ^{webPath}(.+)? {
|
location ~ ^{webPath}(.+)? {
|
||||||
alias {publicPath};
|
alias {documentRoot};
|
||||||
index index.php;
|
index index.php;
|
||||||
try_files $1 $uri $uri/ {webPath}/index.php$is_args$args;
|
try_files $1 $uri $uri/ {webPath}/index.php$is_args$args;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user