0

Apache 服务器无法在 Windows Server 2016 上运行的单个公共 IP 上托管多个域

错误:“未找到请求的 URL / 在此服务器上未找到。” 404 未找到

到目前为止的进展:

1)编辑Windows主机文件“C:\Windows\System32\drivers\etc\hosts”:到下面

127.0.0.1       localhost
::1             localhost
127.0.0.1       koffeeroasters.com

2)Apache的httpd.conf文件中所做的更改如下

改变了

#Include conf/extra/httpd-vhosts.conf

Include conf/extra/httpd-vhosts.conf

也变了

#LoadModule rewrite_module modules/mod_rewrite.so

LoadModule rewrite_module modules/mod_rewrite.so

并在文件末尾添加以下内容

# Tells Apache to identify which site by name
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wampstack/apache2/htdocs"
</VirtualHost> 
# Tells Apache to serve Client 1's pages to "client1.localhost"
# Duplicate and modify this block to add another client
<VirtualHost 127.0.0.1>
# The name to respond to
ServerName koffeeroasters.com
ServerAlias www.koffeeroasters.com
# Folder where the files live
DocumentRoot "C:/wampstack/apache2/htdocs/koffeeroasters.com/"
# A few helpful settings...
<Directory "C:/wampstack/apache2/htdocs/koffeeroasters.com/">

Order Allow,Deny
Allow from all
# Enables .htaccess files for this site
AllowOverride All
</Directory>
# Apache will look for these two files, in this order, if no file is specified in the URL
DirectoryIndex index.html index.php
</VirtualHost>

其他详情

我在 bitnami wampstack 上使用 apache 服务器。

从服务器浏览器键入地址“koffeeroasters.com”时,站点可用。

一个我不知道解决方案的原因(引用自 apache 文档“ https://httpd.apache.org/docs/2.4/vhosts/examples.html ”):

注意:在 Apache 服务器上创建虚拟主机配置不会神奇地导致为这些主机名创建 DNS 条目。您必须在 DNS 中有名称,解析为您的 IP 地址,否则其他人将无法看到您的网站。您可以将条目放在主机文件中以进行本地测试,但这仅适用于具有这些主机条目的机器。

谢谢一堆。所有帮助表示赞赏。

4

1 回答 1

0

尝试改变这个:

<VirtualHost 127.0.0.1>

<VirtualHost *:80>

这意味着允许任何其他 IP 在端口 80 上连接,这应该可以帮助您。尝试匹配本地主机可能比您需要的更多,除非您是面向公众的服务器,在这种情况下您不会想要这样做。

于 2017-01-24T14:13:20.920 回答