apache 虚拟主机设置不起作用

apache vhost setup doesnt work

首先要做的是..我对 apache 配置还很陌生。

我正在尝试为 apache 在本地配置虚拟主机 (Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 根据 phpinfo()).

它是通过 XAMPP (xampp-win32-5.6.3-0) 设置的。 操作系统是 Windows 7 Home Premium SP1。

所以我已经阅读了一些关于设置虚拟主机的文章(本论坛中也有一些)。 我的主机文件如下所示:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   ::1             localhost
    127.0.0.1       localhost
    127.0.0.1   test.local

我的C:\xampp56\apache\conf\extra\httpd-vhosts.conf包含以下代码:

<VirtualHost *:80>
    ServerName test.local
    ServerAlias test.local
    DocumentRoot "C:/xampp56/htdocs/test.local"
    DirectoryIndex app.php
</VirtualHost>

加载到C:\xampp56\apache\conf\httpd.conf文件中

Include conf/extra/httpd-vhosts.conf

模块 mod_log_config.so 也加载到 httpd.conf

LoadModule log_config_module modules/mod_log_config.so

(在对配置文件进行所有编辑后,我保存了它们并重新启动了 apache。)

当我在 FireFox 中键入 test.local(或 http://test.local)时,它总是显示 "test.local was not found"。当我调用本地主机时,它正在工作。

我还没有找到任何答案,除了检查虚拟主机和主机文件是否设置正确(对我来说似乎就是这种情况)。

抱歉这么久了 post,如果我在这里犯了一些愚蠢的错误,我很抱歉。

感谢任何帮助!

编辑:

这也是 httpd -S 命令的输出:

VirtualHost configuration:
*:80                   test.local (C:/xampp56/apache/conf/extra/httpd-vhosts.conf:44)
*:443                  www.example.com (C:/xampp56/apache/conf/extra/httpd-ssl.conf:80)
ServerRoot: "C:/xampp56/apache"
Main DocumentRoot: "C:/xampp56/htdocs"
Main ErrorLog: "C:/xampp56/apache/logs/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/xampp56/apache/logs/" mechanism=default
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
PidFile: "C:/xampp56/apache/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG

我找到了解决方案。 是 Avira 阻止了对我的主机文件的访问。在 avira 中禁用了该选项,虚拟主机现在可以正常工作了。

除此之外,我需要管理员权限,但我使用的帐户并未设置这些权限..