简体   繁体   English

Apache httpd 虚拟主机无法访问

[英]Apache httpd virtual host is not accessible

I am a newbie to linux, I was able to setup my LAMP server on Manjaro.我是 linux 的新手,我能够在 Manjaro 上设置我的 LAMP 服务器。 Was getting the hang of everything but now having problems setting my virtual host.已经掌握了一切,但现在在设置我的虚拟主机时遇到了问题。 I am using httpd and commented out the "Include conf/extra/httpd-vhosts.conf" in /etc/httpd/conf/httpd.conf .我正在使用 httpd 并注释掉/etc/httpd/conf/httpd.conf 中“Include conf/extra/httpd-vhosts.conf” But couldn't visit the host after editing the httpd-vhosts.conf .但是编辑httpd-vhosts.conf后无法访问主机。 After searching through the web for solution, the latest I got was,在网上搜索解决方案后,我得到的最新消息是,

# 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>

But dummy.local doesn't load and says,但是 dummy.local 没有加载并说,

This site can't be reached无法访问此站点
dummy.local's server IP address could not be found.找不到 dummy.local 的服务器 IP 地址。

Thank you.谢谢你。

After troubleshooting some basics steps, I got around my problem by simply adding the ServerName of my virtual host to /etc/hosts as在对一些基本步骤进行故障排除后,我通过简单地将我的虚拟主机的ServerName添加到/etc/hosts作为解决了我的问题

127.0.0.1 dummy.local 127.0.0.1 dummy.local

That solved it for me.那为我解决了。 Hope this helps someone else as well.希望这对其他人也有帮助。 Have a good day.祝你有美好的一天。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM