Question

How to connect to my local site from another PC on my local network ?

Hello Justin, I don’t know it the comments on the post about virtual host on ubuntu are still active but two things please :

  • first, your tutorial is perfectly clear and efficient (congratulations)

  • Second point is a question please :

Once we have set-up a Virtual Host, my problem is that I can’t reach the corresponding local site from another PC on the local network (precisely, i would like to connect to my local site from a smartphone connected to the local network).

So, I have a local site on /var/www/html/asite/ with a index.php inside. I have created a virtual host “asite.com” for this site and when i am on the PC, I can get to this site, either by typing “asite.com” or “localhost/asite”.

FROM THE PC: If I enter “asite.com” or “192.68.0.10/asite” it goes automatically on “localhost/asite”, but it ‘works’ and I can see my site…(yet, i don’t understand why it goes to “localhost/asite” and doesnt stay on asite.com…)

FROM A PHONE ON THE LOCAL NETWORK: I can reach a file like /var/www/html/ATestDir/index.php on my PC, just by entering 192.68.0.10/ATestDir/ …This is OK… But unfortunately, if (FROM MY PHONE) I try to connect to my site by typing “asite.com” or even “192.68.0.10/asite/” or whatsoever… it goes automatically to localhost/asite and says that localhost doesn’t allow the connexion…

My /etc/hosts shows this :

#a first Virtual Host : 192.168.0.10 asite.com 127.0.1.1 pierre-Satellite-L500 #another VirtualHost 127.0.0.1 crud.fr

The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback ip6-dracard.fr fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters *

By any chance, would you have an idea to solve this problem ? thank you in advance, Pierre


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @bastringue,

Your best bet would be to setup a DNS record that points to your server so that all devices within your network can reach the desired server. An alternative would be to update all of the computers on your network with the hosts entry as needed, but there’s no easy way to do this for phones unfortunately