通过网络访问本地主机 Web 服务器
我使用本地计算机作为开发服务器。我的主机文件设置如下:
127.0.0.1 localhost
127.0.0.1 cdog24
127.0.0.1 xxxxxorg
127.0.0.1 newintranet
我的 httpd-vhosts.conf 文件设置如下:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs"
ServerName localhost
ServerAlias localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\cdog24"
ServerName cdog24
ServerAlias cdog24
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\xxxxxorg"
ServerName xxxxxorg
ServerAlias xxxxxorg
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\newintranet"
ServerName newintranet
ServerAlias newintranet
</VirtualHost>
我正在运行 xampp,并且可以通过输入以下内容分别访问本地计算机上的每个站点:
http://localhost http://cdog24 http://xxxxxorg http://newintranet
当我转到网络上的另一台计算机时,我假设我必须输入我的计算机的名称或使用 IP 地址。因此,当我输入以下内容时:
http://machinename/cdog24 或 http://10.1.0.24/newintranet
我被带到 404 页面。
我缺少什么?本地计算机或网络上的防火墙不受影响,因为它们都已关闭。我在 Windows 7 本地计算机上,远程计算机也是 Windows 7。
感谢您的帮助。
I am using my local machine as a development server. I have my hosts file set up as such:
127.0.0.1 localhost
127.0.0.1 cdog24
127.0.0.1 xxxxxorg
127.0.0.1 newintranet
My httpd-vhosts.conf file is set up as follows:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs"
ServerName localhost
ServerAlias localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\cdog24"
ServerName cdog24
ServerAlias cdog24
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\xxxxxorg"
ServerName xxxxxorg
ServerAlias xxxxxorg
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\Webserver\htdocs\newintranet"
ServerName newintranet
ServerAlias newintranet
</VirtualHost>
I am running xampp and can access each site on my local machine respectively by typing in:
http://localhost
http://cdog24
http://xxxxxorg
http://newintranet
When i go to a different computer on my network, I assume I have to type int he name of my machine or use the IP address. So, when I type in the following:
http://machinename/cdog24 or http://10.1.0.24/newintranet
I am taken to a 404 page.
What am I missing? Firewall on local machine or network do not factor as they are both off. I am on a Windows 7 local machine, the remote machine is also Windows 7.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要编辑远程计算机(运行浏览器而不是服务器)上的主机文件:
将 xxxx 更改为运行服务器的 Windows 机器的 IP 地址。
现在您应该可以在浏览器中浏览到 http://cdog24/。
但是,请勿添加指向另一台计算机的本地主机条目。 localhost 应始终指向 127.0.0.1!
You will need to edit the hosts file on the remote machine (where the browser is running, not the server):
Change x.x.x.x to the IP address of the Windows box that is running the server.
Now you should be able to browse to, say http://cdog24/ in your browser.
However, do NOT add a localhost entry that points to the other machine. localhost should always point to 127.0.0.1!
您是否尝试过 http://machinename/ ?
http://machinename/directory 要求文档根目录指向 htdocs 本身。
Have you tried with just http://machinename/ ?
http://machinename/directory would require that the document root be pointing to htdocs itself.
您需要计算出您的计算机在网络上的 IP 地址,然后编辑其他计算机上的主机文件以指向您的计算机
您可能还需要更新 apache conf 文件以从您的网络地址而不是 127.0.0 开始工作.0.1。
You need to work out what the IP address of your machine is on your network, and then edit teh hosts files on the other machines to point to yours
You maybe also have to update the apache conf file to work from your network address rather than 127.0.0.1.