Access the Apache virtual host (Subdomain) using another computer on the local network

I'm currently trying to configure the virtual host (Subdomain) of my Apache HTTP server so that it can be accessed from another computer on the local network. The current Apache setup with PHP and MySQL runs locally on the same physical machine.

So, I have two Virtual Host installations (development and cms) running on a non-standard port 50080. The server machine has IP 10.0.0.10. On the same physical machine, I can access two virtual hosts using:

development.localhost:50080 cms.localhost:50080 

On another physical machine, I can access the server root using:

 10.0.0.10:50080 

But I can not or do not know how to access the virtual host from another machine. I tried something like:

 development.10.0.0.10:50080 cms.10.0.0.10:50080 

But they do not seem to work.

This is what 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 other posts here and the Apache forum, but there is no specific case for this.

I was wondering how I can access the virtual host (subdomain) from another computer and maintain the same port, if possible.

Thanks in advance

+8
apache virtualhost
source share
5 answers

Ok, I get it, here is the configuration if someone else is looking for this:

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

Machine A (Apache HTTP Server): HTTPD Host:

 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 

On the second computer, you can access using the "alias" and "development.alias"

+25
source share

I suggest making the following change (add ServerAlias ​​lines):

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

Restart Apache to ensure that the changes take effect.

Then on your second computer, you need to add a custom dns entry for these new domain names. If it is Windows, edit the file c:\windows\system32\drivers\etc\hosts . If it is Linux, edit / etc / hosts. In any case, add:

 10.0.0.10 development.myserver.com 10.0.0.10 cms.myserver.com 

Now on your second computer, you can access the following URLs:

 http://development.myserver.com:50080 http://cms.myserver.com:50080 
+3
source share

If something is missing for me, you need to either configure DNS records or add records to the / etc / hosts file of each computer accessing the server.

localhost is the entry that exists in all default / etc / hosts files, always pointing to 127.0.0.1. developer.localhost does not exist without adding the / etc / hosts entry, and the IP address prefix with the subdomain does not work at all.

+2
source share

For Named Virtual Hosts you need to use the host name or domain name to connect to your apache server. This does not work with ips.

You can insert an entry in your /etc/hosts into your second system.

0
source share

Using the SSH + Putty tunnel and thus having 127.0.0.1 on my server, I was able to access my subdomains by following these steps on my server side:

 # nano /etc/hosts 127.0.0.1 localhost.localdomain localhost 127.0.0.1 sub1.domain.com sub2.domain.com sub3.domain.com sub4.domain.com 

I have not changed the host file of the remote computer and it works like a charm

0
source share

All Articles