Unable to view 2 local sites over network

Posted by gentrobot on Pro Webmasters See other posts from Pro Webmasters or by gentrobot
Published on 2012-09-09T10:34:22Z Indexed on 2012/09/09 15:50 UTC
Read the original article Hit count: 240

Filed under:
|

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/site1.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) ?

© Pro Webmasters or respective owner

Related posts about apache2

Related posts about virtualhost