Apache虚拟主机(子域)与不同的局域网电脑上网 [英] Apache Virtual Host (Subdomain) access with different computer on LAN

查看:186
本文介绍了Apache虚拟主机(子域)与不同的局域网电脑上网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在试图配置我的Apache HTTP服务器的虚拟主机(子域),因此它可以与我的局域网上的其他计算机访问。阿帕奇的PHP与MySQL的当前设置本地工作在同一物理机上。

所以,我有两个虚拟主机设置(发展和CMS)的一个50080.非默认端口上运行的服务器的机器有一个10.0.0.10 IP。从同一台物理机器,我可以通过访问这两个虚拟主机:

  development.localhost:50080
cms.localhost:50080

从不同的物理机器,我可以通过访问服​​务器的根目录:

  10.0.0.10:50080

但我不能或不知道如何从不同的计算机访问的虚拟主机。我想是这样的:

  development.10.0.0.10:50080
cms.10.0.0.10:50080

但他们似乎没有工作。

下面是如何我的httpd的虚拟主机文件如下:

  *了NameVirtualHost:50080
<虚拟主机*:50080>
    的DocumentRootC:/网络/ HTTP
    服务器名本地主机
< /虚拟主机><虚拟主机*:50080>
    的ServerAdmin administrator@development.localhost
    的DocumentRootC:/网络/ HTTP /发展
    服务器名development.localhost
    错误日志记录/ development.localhost-error.log中
    的CustomLog日志/ development.localhost-access.log的共同
< /虚拟主机>

我看了这里的一些其他职位和Apache论坛,但有不准确的情况下这一点。

我不知道我怎么可以从其他计算机访问虚拟主机(子域),如果可能,保持相同的端口。

在此先感谢


解决方案

好吧,我想通了,这里有其他人是否寻找这个配置:

=============================================== ===================================


  

机A(Apache HTTP服务器):
  的httpd的虚拟主机:


  *了NameVirtualHost:50080<虚拟主机*:50080>
    的DocumentRootC:/网络/ HTTP
    服务器名本地主机
    ServerAlias​​别名<! - 新增 - >
< /虚拟主机><虚拟主机*:50080>
    的ServerAdmin administrator@development.localhost
    的DocumentRootC:/网络/ HTTP /发展
    服务器名development.localhost
    ServerAlias​​ development.phoenix<! - 新增 - >
    错误日志记录/ development.localhost-error.log中
    的CustomLog日志/ development.localhost-access.log的共同
< /虚拟主机>


  

主机:


  127.0.0.1 development.localhost127.0.0.1的别名
127.0.0.1 development.alias

=============================================== ===================================


  

机B(客户机):
  主机:


  10.0.0.10别名
10.0.0.10 development.alias

从第二台机器,你应该能够以别名和development.alias访问

I am currently trying to configure the Virtual Host (Subdomain) of my Apache HTTP Server so it can be accessed with another computer on my LAN. The current setup of Apache with PHP and MySQL works locally on the same physical machine.

So I have two Virtual Host setup (development and cms) running on a non-default port of 50080. The machine of the server have a IP of 10.0.0.10. From the same physical machine, I can access the two Virtual Host using:

development.localhost:50080
cms.localhost:50080

From a different physical machine, I can access the root of the server using:

10.0.0.10:50080

But I cannot or do not know how to access the Virtual Host from the different machine. I tried something like:

development.10.0.0.10:50080
cms.10.0.0.10:50080

But they do not seem to work.

Here's how my httpd-vhosts file looks like:

NameVirtualHost *:50080
<VirtualHost *:50080>
    DocumentRoot "C:/www/HTTP"
    ServerName localhost
</VirtualHost>

<VirtualHost *:50080>
    ServerAdmin administrator@development.localhost
    DocumentRoot "C:/www/HTTP/development"
    ServerName development.localhost
    ErrorLog "logs/development.localhost-error.log"
    CustomLog "logs/development.localhost-access.log" common
</VirtualHost>

I read some of the other post here and the Apache forum, but there's not exact case for this.

I was wondering how I can access the Virtual Host (Subdomain) from another machine and keep the same port if possible.

Thanks in advance

解决方案

Ok, I figured it out, here are the configuration if anyone else is looking for this:

==================================================================================

Machine A (Apache HTTP Server): httpd-vhost:

NameVirtualHost *:50080

<VirtualHost *:50080>
    DocumentRoot "C:/www/HTTP"
    ServerName localhost
    ServerAlias alias <!-- Added -->
</VirtualHost>

<VirtualHost *:50080>
    ServerAdmin administrator@development.localhost
    DocumentRoot "C:/www/HTTP/development"
    ServerName development.localhost
    ServerAlias development.phoenix <!-- Added -->
    ErrorLog "logs/development.localhost-error.log"
    CustomLog "logs/development.localhost-access.log" common
</VirtualHost>

hosts:

127.0.0.1 development.localhost

127.0.0.1 alias
127.0.0.1 development.alias

==================================================================================

Machine B (Guest Machine): hosts:

10.0.0.10 alias
10.0.0.10 development.alias

From the second machine, you should be able to access with "alias" and "development.alias"

这篇关于Apache虚拟主机(子域)与不同的局域网电脑上网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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