Mobile app version of vmapp.org
Login or Join
Si4351233

: Unable to view 2 local sites over network I have 2 websites running on my local machine that I'd like to view from other machines on the same network. For /etc/apache2/sites-available/site1.com:

@Si4351233

Posted in: #Apache2 #Virtualhost

I have 2 websites running on my local machine that I'd like to view from other machines on the same network.

For /etc/apache2/sites-available/site1.com:

<VirtualHost *:80>
ServerName site1.com
DocumentRoot /var/www/answers/app/webroot
DirectoryIndex index.php

<Directory "/var/www/answers/app/webroot">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


For /etc/apache2/sites-available/site2.com:

<VirtualHost *:80>
ServerName site2.com
DocumentRoot /var/www/answers2/app/webroot
DirectoryIndex index.php

<Directory "/var/www/answers2/app/webroot">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


I have added 2 entries in the /etc/hosts file as:

127.0.0.1 site1.com
127.0.0.1 site2.com


Now, when I point the browser on my machine to site1.com, it shows me the first site and pointing the browser to site2.com, it shows me the second site.

However,when I type in the local IP of my machine in the browser, it always shows site2. How can I change it to switch between site1 and site2 ? Is there a way that I can view both the sites form another machine (esp. mobile devices over wireless network) ?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si4351233

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

On the other machine you would ordinarily add corresponding entries to the machines host file (as you have done on your machine) - pointing to the local IP address of your web server.

192.168.XXX.XXX site1.com
192.168.XXX.XXX site2.com


However, unless your mobile device (eg. phone?) is rooted, then you probably don't have access to the hosts file.

I think the ultimate/correct solution is to run a local DNS server: android.stackexchange.com/questions/9633/manually-set-a-hostname-for-ip-address-i-e-etc-hosts-equiv
However, you might be able to do this if your device supports an Ad Hoc network: android.stackexchange.com/questions/26692/connect-to-laptops-localhost-websites

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme