在2.4.7中创建Apache别名

问题描述 投票:0回答:2

我的服务器ip是内部的(我不必在互联网上发布)192.168.251.4

我在/ opt / observium / html /文件夹中有一个站点,我想到达在浏览器中编写http://192.168.251.4/observium的站点。

我尝试使用虚拟主机但没有成功。

操作系统:Ubuntu服务器14.04LTS Apache版本:2.4.7

谢谢!

web apache2 virtual hosts observium
2个回答
1
投票

以下是我更多地使用apache中的“Alias”功能,但是你还需要为observium做另一件工作才能使它工作:

在Apache(基于ubuntu)中我添加了文件/etc/apache2/conf-available/observium.conf

<IfModule mod_alias.c>
    Alias /observium /opt/observium/html/
</IfModule>
<Directory /opt/observium/html/>
    Options FollowSymLinks
    AllowOverride None
    <FilesMatch \.php$>
      SetHandler application/x-httpd-php
    </FilesMatch>
    DirectoryIndex index.php
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

然后激活配置(再次指的是RH变种中的ubuntu会略有不同):

a2enconf observium
systemctl reload apache2

由于观察站希望使用网站的/作为参考,你需要在/opt/observium/config.php更新它并添加以下行:

$config['base_url'] = "http://" . $_SERVER["SERVER_NAME"] . ":".$_SERVER["SERVER_PORT"] . "/observium/";

(请注意尾随/

更新:上面的过程遗漏了最后一个更改:(来源:http://www.foobar.org/~nick/OBSERVIUM-11.html)编辑文件/opt/observium/html/includes/functions.inc.php并更改以下行:

$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
to:
$segments = explode('/', trim($_SERVER['PATH_INFO'], '/'));

0
投票

有点奇怪的是,在标题中你知道它是一个“别名”,但你没有提到使用Alias指令。

应该如此简单

Alias /observium  /opt/observium/html
<Directory  /opt/observium/html/>
  Require all granted
</Directory>
© www.soinside.com 2019 - 2024. All rights reserved.