基于 IP 的 VirtualHost 和 Apache
我有一个网络服务器,其 IP 地址为 xxx.xxx.xx.x,我还有一个要发布的网站,但我的网站还没有任何域名。
因此,在我的 httpd-vhosts.conf
文件中,我有这样的设置:
<VirtualHost xxx.xxx.xx.x>
ServerName xxx.xxx.xx.x
DocumentRoot "C:\Sites\mysite"
</VirtualHost>
由于我没有域,我真的想使用 IP 地址来访问我的网站,但我已经尝试过这个,但它没有工作。我想您必须按照标题所述在 ServerName
中设置服务器名称。
有什么方法可以通过我的 IP 地址公开我的网站吗?如果可以,我该怎么做?
I have this webserver that have an IP address xxx.xxx.xx.x, I also have a website I want to publish, but I do not have any domain for my website yet.
So in my httpd-vhosts.conf
file I have this setting:
<VirtualHost xxx.xxx.xx.x>
ServerName xxx.xxx.xx.x
DocumentRoot "C:\Sites\mysite"
</VirtualHost>
And since I dont have a domain I really want to use the IP address to reach my site, but I have tried this and it does not work. I guess you HAVE to set a server name in ServerName
as the title says.
Are there any ways for me to make my website public through my IP address, if yes how can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试
记住重新启动apache,
您可能还需要添加,
Try
Remember to restart apache,
You may also need to add,
如果您在这台服务器上只有一个网站,则不需要虚拟主机。只需正确设置 DocumentRoot 即可。还要确保 Apache 正在侦听所有 IP 地址(侦听 0.0.0.0:80)。
如果这对您不起作用,请在命令提示符下执行:
并查看返回的内容 - 您应该获得网站的默认页面。
If you only have the one website on this server, you don't need a virtual host. Just set the DocumentRoot correctly and away you go. Also make sure Apache is listening on all IP addresses (Listen 0.0.0.0:80.)
If that doesn't work for you, from your command prompt do:
and see what you get back - you should get your website's default page.
这不是一个编程问题。
但无论如何,
将 VirtualHost 设置为 * 而不是特定的 IP 地址。我认为您也不需要服务器名称。
This is not a programming question.
But anyway,
Set the VirtualHost to * rather than a specific IP address. I don't think you need the servername either then.