Apache httpd 虚拟主机无法访问

Apache httpd virtual host is not accessible

我是 linux 的新手,我能够在 Manjaro 上设置我的 LAMP 服务器。掌握了一切,但现在在设置我的虚拟主机时遇到了问题。我正在使用 httpd 并在 /etc/httpd/conf/httpd.conf 中注释掉 "Include conf/extra/httpd-vhosts.conf"。但是编辑httpd-vhosts.conf后无法访问主机。在网上搜索解决方案后,我得到的最新信息是,

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

NameVirtualHost *:80

<VirtualHost *:80> 
    ServerAdmin dummy@gmail.com 
    DocumentRoot "/srv/http/sami" 
    ServerName dummy.local 
    ErrorLog "/srv/http/sami/dummy-host.example.com-error_log" 
    CustomLog "/srv/http/sami/dummy-host.example.com-access_log" common 
</VirtualHost>

<VirtualHost *:80> 
    ServerAdmin dummy@gmail.com 
    DocumentRoot "/srv/http" 
    ServerName localhost 
    ErrorLog "/srv/http/error-log" 
    CustomLog "/srv/http/access-log" common 
</VirtualHost>

但是 dummy.local 没有加载并说,

This site can’t be reached
dummy.local’s server IP address could not be found.

谢谢。

在对一些基本步骤进行故障排除后,我通过简单地将虚拟主机的 ServerName 添加到 /etc/hosts[=17= 来解决我的问题] 作为

127.0.0.1 dummy.local

这帮我解决了。希望这对其他人也有帮助。祝你有个美好的一天。