IP地址无法在apache中转换为主机名

时间:2015-03-30 11:15:08

标签: apache

我正在尝试在apache2 webserver上配置和托管我的静态html页面。

但它没有将ip地址转换为主机名。

这是我在var / www / default文件中的配置

<VirtualHost *>
    ServerName gameplayer.com
    ServerAlias www.gameplayer.com
    DocumentRoot /var/www/gameplayer
    CustomLog /var/www/logs/gameplayer.log combined
    ErrorLog /var/www/logs/gameplayer.log
<VirtualHost>

当我尝试加载时,显示没有找到页面错误。

当我通过ip add-192调用它时。。*它显示了一个网站列表。 当我点击其中一个时,我的网站路径是

    192.*.*.*/websitename.

相反,我想加载没有ip地址前缀的网站。

由于我是学习者,我不知道问题出在哪里?请帮帮我。

请有人告诉我如何在两个不同的端口上的同一个Web服务器上托管两个不同的网站?

[编辑]

Listen 8999

NameVirtualHost 127.0.0.1:8999


<VirtualHost 127.0.0.1:8999>
    ServerName gameplayer.com
    ServerAlias www.gameplayer.com
    DocumentRoot /var/www/gameplayer-8999
    CustomLog /var/www/logs/gameplayer.log combined
    ErrorLog /var/www/logs/gameplayer.log
<VirtualHost>

1 个答案:

答案 0 :(得分:2)

如何在localhost上运行/测试(从评论中提取)

您需要编辑主机文件。在* nix操作系统上,此文件通常位于/etc/hosts,在Windows系统上通常为c:\Windows\System32\Drivers\etc\hosts

你需要遵循文件的格式并添加这样的东西。

192.x.x.x   gameplayer.com www.gameplayer.com

或者如果您在localhost上执行此操作,请将192.x.x.x.替换为127.0.0.1(如果使用ipv6,则替换为::1 - 或者只将主机名添加到localhost的现有条目中)

相关问题