我的便携式Windows 7机器上安装了一个apache服务器,使用xampp作为接口。我一直在与一些人在irc频道上工作,但必须很快上床睡觉,回复越来越慢。
我将以下代码添加到我的httpd.conf文件中:
#virtual servers
#Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost.MEALS
DocumentRoot C:\xampp\htdocs\MEALS
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.HA
DocumentRoot C:\xampp\htdocs\Hackers
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.WIK
DocumentRoot C:\xampp\htdocs\WhoIKnow
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.TUS
DocumentRoot C:\xampp\htdocs\Unity
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.PHP
DocumentRoot C:\xampp\htdocs\phpMyAdmin
DirectoryIndex index.php
</VirtualHost>
我有以下配置:
Setting environment for using XAMPP for Windows.
John@ASSIMILATER C:\xampp
# httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 localhost (C:/xampp/apache/conf/extra/httpd-ssl.conf:80)
*:80 is a NameVirtualHost
default server localhost.MEALS (C:/xampp/apache/to which there was conf/httpd.conf:512)
port 80 namevhost localhost.MEALS (C:/xampp/apache/conf/httpd.conf:512)
port 80 namevhost localhost.HA (C:/xampp/apache/conf/httpd.conf:516)
port 80 namevhost localhost.WIK (C:/xampp/apache/conf/httpd.conf:520)
port 80 namevhost localhost.TUS (C:/xampp/apache/conf/httpd.conf:524)
port 80 namevhost localhost.PHP (C:/xampp/apache/conf/httpd.conf:528)
Syntax OK
John@ASSIMILATER C:\xampp
#
然而,当我尝试在我的网络浏览器中访问localhost.PHP时,它告诉我找不到服务器。我被告知我需要解析机器上的主机名。我被引导到一些没有回复的irc频道(dns和windows)。我搜索了谷歌并浏览了这个网站:http://technet.microsoft.com/en-us/library/bb727005.aspx#EEAA。我不太确定我正在读什么,并且尽可能接近它并没有给我一个明确的指示,说明在哪里解析主机名或要编辑的文件。
目前,默认服务器是代码中的顶级虚拟服务器。我想调用localhost并显示我创建的一个简单的html页面,它位于“htdocs / index.html”中,它将导航到其他服务器(指向“localhost.PHP”等的链接)。有没有办法让默认服务器保持“localhost”,在维护其他虚拟服务器时指向“htdocs / index.html”,或者我是否必须创建另一个虚拟服务器并将其设为默认服务器?
任何和所有帮助表示赞赏。
编辑:我有人帮我在我的机器上找到HOSTS文件,但无法编辑它。我关闭了所有防病毒功能,关闭spybot(UAC总是关闭,我总是以管理员权限运行)专门右击np ++ editpadlite和Windows记事本,只能在记事本中编辑,但需要保存文件不同的名字。
答案 0 :(得分:0)
您必须以管理员身份显式运行记事本(无论UAC设置如何),当您去保存时,请确保选择“所有文件”而不是默认的* .txt。
当我尝试在W7上编辑hosts文件时,我发现了同样的事情,但似乎只是作为管理员在机器上与显式以管理员身份运行程序并不完全相同。