Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Virtual Host (Subdomain) access with different computer on LAN

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 [email protected]
    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

like image 791
YTKColumba Avatar asked Aug 21 '11 22:08

YTKColumba


1 Answers

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 [email protected]
    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"

like image 82
YTKColumba Avatar answered Nov 15 '22 18:11

YTKColumba