我的服务器 ip 是内部的(我不必在互联网上发布)192.168.251.4
我在 /opt/observium/html/ 文件夹中有一个站点,我想在浏览器中访问写http://192.168.251.4/observium的站点。
我尝试使用虚拟主机但没有成功。
操作系统:Ubuntu 服务器 14.04LTS Apache 版本:2.4.7
谢谢!
按照 covener 的回答,我也在 apache 中使用了“别名”功能,但您还需要为 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
由于 observium 期望使用/
站点的作为参考,因此这还行不通,您需要更新它/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'], '/'));
有点奇怪,在标题中您知道这是一个“别名”,但您没有提到使用 Alias 指令。
应该很简单
Alias /observium /opt/observium/html
<Directory /opt/observium/html/>
Require all granted
</Directory>