Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

faiz's avatar
Level 3

How To Make Virtual Hosts Accessible From LAN

Hi All,

I'm just new with Laravel. I need help on how to setup my virtual host so that everybody in the LAN network can access. It is just for internal use only. I have no experience in web development so have no idea how to do it. i already google and try but still not working. Only the server can access the virtual host. Right now I just make my PC as a server. I'm using windows 7 and WAMP server.

There will be more apps on this server, so i want to create virtual host for each app to make it easier for user to access. Or is there any other way I can do to deploy each Laravel app in my office server. No one ever use any framework in this company, that's why no one in office can help.

If its not possible to use virtual host, then what is the best way for me to deploy laravel app in my office. I really need some suggestion and help to setup this thing in my office. I really love using Laravel instead of writing PHP from scratch or using other PHP framework.

I did try everything that I found on the net but still not get what i want. I try to follow a tutorial on how to deploy laravel using shared hosting, it work. But, I cannot remove "public" from the url. I also cannot redirect all request to the laravel folder. Here's what i mean:

http:://localhost/laravel/public <------- the homepage. i cannot remove "public"

In my template, whene I use "/" for my homepage link, I cannot redirect the request to the "laravel" folder, its always go to the root, "loaclhost".

I try edit the .htaccess but not working.

Now i'm really dont know what to do. Hope u guys can help me solve my issue. I just want to deploy laravel locally and everybody in the LAN network can access it.

Thanks

0 likes
11 replies
layer7's avatar

Try turning off the Windows Firewall. If that makes it work, I'll go in to more detail about how to do it properly.

1 like
ohffs's avatar

I'm not a Windows user, but I assume your WAMP has a setting for which IP address it's listening on. It's possibly set to "127.0.0.1" (aka 'localhost') - if you change that to your machines actual IP address then you should be able to access it from your LAN. If you've got a firewall you might need to allow port 80 (and/or 443) too.

For your 'public' problem - it might be that your apache config has AllowOverride None set - if so try changing it to AllowOverride All and restarting. That's just a guess though - it's hard to say without any details.

1 like
faiz's avatar
Level 3

@ohffs @layer7 thanks for reply. Sorry i forgot to tell that i already open port 80, 81, 82 in my firewall. I can access using the server IP.

http://192.168.1.104:81/ <------- this work

http://myApp.local/ <------ other PC in LAN cannot access, only the server PC can. can we make it also accessible from other PC in LAN? I've read about dynamic dns things but dont understand it.

@ohffs where can i set "AllowOverride All"? httpd.conf?

thanks

layer7's avatar

Ah yes I understand what you were asking now. Basically you would need

  1. A DNS server on your network where you can configure this hostname to point to the IP Address OR
  2. Add an entry in the hosts file for every machine in the network (not practical of course)

Some routers have the ability to define static DNS entries, but that really depends heavily on the brand and model. You can use Dynamic DNS, but that's mostly to get to a working hostname from the outside world in, not really meant for local IP resolution. If you really want a hostname instead of an IP address, you could use xip.io for example, like this:

http://myApp.192.168.1.104.xip.io

This will resolve to the IP address 192.168.1.104. If you then want another app to be running on the same IP, you could just use:

http://myOtherApp.192.168.1.104.xip.io

I hope that answers your question.

1 like
faiz's avatar
Level 3

@layer7 thanks. option 2 is not practical coz too many PC in office. So no choice, have to take option 1. About xip.io, is it secure? Is there any security issue i need to consider before using it? Is there any way i can run my own dynamic dns server , like using wamp for apache?

layer7's avatar

@faiz There no real security issue here, but your clients need to be connected to the internet to have it work. xip.io would actually be Option 3, you don't need a DNS server in that case.

Option 1, if you decide to go that route:

1 like
ohffs's avatar

@faiz if you're on one of your other machines you could try running nslookup 192.168.1.104 - if it comes back with a name then you've got some kind of local dns that you can use. For the AllowOverride that's in the main httpd.conf or alternatively in the .conf file for your vhost. I don't know enough about WAMP to tell you where to look though. On Linux it'd be in /etc/httpd or /etc/apache2. Hopefully you can do a search for httpd.conf though :-)

1 like
faiz's avatar
Level 3

Hi all,

Sorry for the late reply. I think i need to setup my own dns server. I try to google and follow few tutorials about bind9 on windows 7, but i couldn't make it work. I dont have knowledge in network, so its hard for me to follow the tutorial. I want to setup bind9 in my windows 7 machine. I already install bind9 on my pc.

ip address for the server is 192.168.1.10 i want it to be called as myApp.dev

Can you help me, and guide me to setup this on my pc so that everyone in my LAN network can access that server by typing http://myApp.dev/ in their browser?

thanks

abdelrahman's avatar

hi open up your router configuration web service (usually on 192.168.1.1 ) go to DNS service->Hosts and add the Virtual Host Name (like the one defined in wamp ) and map its ip to the server that will make the VH accessible from the Local net work

---Note--- i just tried it my self now and it works :)

yn95's avatar

1- Right click the network icon in the system tray and choose Open Network and Sharing Center.

2- Double click the network connection that you are using to connect to your local network.

3- Click the Properties button on the popup.

4- Select the TCP/IPv4 connection and click the Properties button.

5- Open a new command prompt by clicking the start orb and typing cmd then hitting enter.

6- In the new command prompt window type the command ipconfig and hit enter.

7- Copy over the following values to the TCP/IPv4 configuration popup:

a- IPv4 Address
b- Subnet Mask
c- Default Gateway

Assuming that you previously obtained an IP address automatically via DHCP, copying the values assigned to your machine is the best way to avoid problems initially. Essentially, you are telling your computer that whatever credentials your DCHP manager has assigned to your machine should remain.

8- Once you have supplied credentials to your network configuration, you can click the OK button and close all windows.

==== Configure Apache to Allow Connections ====

virtual hosts also make the hosts file on remote machines cleaner, clearer and simpler

1- Open your Apache vhost configuration file located in C:\wamp\bin\Apache#.#.#\conf\extra\httpd-vhosts.conf, where #.#.# corresponds to the version of Apache that you are running in WAMP.

2- Edit the Directory configuration of the vhost to allow access from the desired IP address(es).

 <VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "c:/wamp/www/laravel/public"
    ServerName myapp.local
    ServerAlias www.myapp.local
    ErrorLog "logs/myapp.local-error.log"
    CustomLog "logs/myapp.local-access.log" common
    <Directory "/">
        Deny from all
        Allow from 127.0.0.1
        Allow from 192.168.1.111 #iPhone
        Allow from 192.168.1.107 #iPad
        Allow from 192.168.1.110 #Apple TV
        # Allow Web Fonts to load over BrowserSync proxy
        <IfModule mod_headers.c>
           SetEnvIfNoCase Origin "https?://(www\.)?(jmyapp\.local|192.168.1.102)(:\d+)?$" AccessControlAllowOrigin=$0
           Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
        </IfModule>
    </Directory>
</VirtualHost>

3- Save the updated vhost configuration and restart Apache (restart WAMP).

==== Update The Hosts File on LAN Computers ====

The hosts file is the first reference in the DNS lookup process. Before your computer goes out the the Web to fetch DNS information, it will look at the hosts file. That is why you must add entries in the hosts file on each computer that you want to point to your local WAMP site(s).

To add entries to your hosts file follow the instructions below.

1- Open the hosts configuration file located at C:\Windows\System32\drivers\etc\hosts in notepad.

2- On a new line, add the IP address of the host machine (the machine running WAMP), followed by the ServerName for the vhost (ie: myapp.local).

3- Save and close the hosts file… and you’re all set!

1 like

Please or to participate in this conversation.