使用端口设置主机文件 [英] Set up host file using port

查看:111
本文介绍了使用端口设置主机文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置我的主机文件

127.0.0.2:5050 domain2.com =>这是一个地域

当在浏览器中domain2.com一个类型,这回我:HTTP错误404请求的资源未找到

when a type in my browser domain2.com, this return me : HTTP Error 404. The requested resource is not found.

我使用了Apache

i use this in apache

<VirtualHost 127.0.0.9:5050>

    ServerAdmin info@domain2.com
    DocumentRoot "C:/Users/My_Dir/LOOP/WebEnginer-2011/domain2_Dir/"
    ServerName domain2.com
    DirectoryIndex index.php index.html index.htm
    ServerAlias www.domain2.com
    ErrorLog "c:/wamp/xxxx/xxxx.log"
    CustomLog "c:/wamp/xxxx/xxxx.log" common
</VirtualHost>

<VirtualHost 127.0.0.9:5050>

    ServerAdmin info@domain2.com
    DocumentRoot "C:/Users/My_Dir/LOOP/WebEnginer-2011/domain2_Dir/admin_Dir/"
    ServerName admin.domain2.com
    DirectoryIndex index.php index.html index.htm
    ServerAlias www.admin.domain2.com
    ErrorLog "c:/wamp/xxxx/xxxx.log"
    CustomLog "c:/wamp/xxxx/xxxx.log" common
</VirtualHost>

但是当我键入 127.0.0.2:5050 我可以看到一个网页。我想用子像admin.domain2.com

but when i type 127.0.0.2:5050 i can see a web page. I want to use subdomain like admin.domain2.com

因为IIS使用端口I不能使用80端口。

i can't use port 80 because IIS use that port.

如何设置我的主机文件,听 domain2.com

How can i set up my host file to listen domain2.com?

推荐答案

这是行不通的,因为hosts文件仅提供主机名映射到IP地址的目的。服务的端口号是不同的概念,而不是由hosts文件,也不是DNS-系统处理。简而言之:你不能在hosts文件提供一个端口号

That won't work since the hosts file only serves the purpose of mapping a hostname to an IP-address. The port number of a service is a different concept and is not handled by the "hosts" file nor the DNS-System. In Short: you can't supply a port number in the "hosts" file.

如果您的网络服务器工作在另一个端口上,你必须提供的URL信息: http://domain2.com: 5050

If your Webserver works on another port, you have to supply that information in the URL: http://domain2.com:5050.

其他唯一的解决方法是配置网络服务器为侦听特定IP,使它们不互相干扰。例如,IIS可以监听127.0.0.1和Apache上127.0.0.2(您已经配置它的方式)。

The only other solution is to configure your Webservers to listen on a specific IP so that they don't interfere with each other. For example the IIS could listen on 127.0.0.1 and the Apache on 127.0.0.2 (the way you have already configured it).

有实现这一与IIS 一个HOWTO。我不知道是否适合127.0.0.x-IP的,但我认为这是值得一试。

There's a HOWTO for achieving that with the IIS. I'm not sure if that works for 127.0.0.x-IP's but I think it's worth a try.

这篇关于使用端口设置主机文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆