Hi,

I am using WAMP on Win7 and my root folder is obviously c:\wamp\www\

On same computer I use http://localhost/project/ to run my project. The question is how do I run same project on other machine which is on same network? Also I rather use a bit human friendly naming for it like http://project.local/

As far as I know I should create a file and place under somewhere which resolves all.

Can you please enlighting me for this issue.

Thanks in advance

The simplest solution on windows would be to modify the hosts file so that project.local resolves to the ip of the wamp machine. I also seem to recall wamp having to be set into "online" mode to serve files outside of localhost.

How do I do it though?

we can also do it by finding the ip of the host machine..open command prompt on windows and type

ipconfig

The local machine ip should be something like IPv4 or something in this pattern 192.xxx.xx.x . This ip can be access by other machines via browser using this http://192.xxx.xx.x/project/ as url.

During the first run, a firewall might block it. Allow the accesss as necessary..

OK, I found hosts file and its content has only this line: 127.0.0.1 localhost

I assume that if I also add 127.0.0.1 project.local I can I access to the project via http://project.local/ from different computer. Am I right or missing something like httpd.conf settings?

Also some guys add extra lines starting with <VirtualHost *:81> .........

Oh EACH remote machine you want to access your wamp machine from, you will need to modify the hosts file.
Add a new line: ###.###.###.### project.local where ###.###.###.### is the IP address of the remote machine on your lan. So a 10.x.x.x. or a 192.x.x.x etc.

If the virtualhost is set to listen on *:80 you won't have an issue. If it is set to listen on *:81 you will need to add :81 after your project.local domain.

IP of server where WAMP is running : 192.168.1.4

If call http://192.168.1.4/ from second computer, it works fine but I need to call http://project.local which is more human friendly but doesn't work.

Can anyone tell me what I am missing?

What I did?

my hosts file:

127.0.0.1 localhost
192.168.1.4 project.local
192.168.1.4 localhost

And my httpd.conf:

  ServerName localhost:80
  NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
   ServerName localhost
   DocumentRoot "C:/wamp/www"
</VirtualHost>

<VirtualHost 127.0.0.1>
   ServerName project.local
   DocumentRoot "C:/mysite"

<Directory C:/mysite>
   Order Allow,Deny
   Allow from all
 </Directory>
 </VirtualHost>

You have modified the hosts file on the second computer and not the server 192.168.1.4 correct?

Hi,

On top of mschroeder's question, does your wamp server have this file in it? => c:\wamp\apache\conf\extra\httpd-vhosts.conf ? I just hate donwloading a copy, because they want me to provide my email address. I already have enough junk mails to deal with on a daily basis.

@ You have modified the hosts file on the second computer and not the server 192.168.1.4 correct?

Am I supposed to do on client machine only? I did it on just server (192.168.1.4).

@ c:\wamp\apache\conf\extra\httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/Apache2/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

As I said previously....

Oh EACH remote machine you want to access your wamp machine from, you will need to modify the hosts file.

The only other option is to create a DNS server just for .local domains and have your computers route through that. However, this is overkill when you just need access for a few machines.

Is there any other way to do it without doing configuring client machines because it is not maintanable? Just on server would be the best....

Member Avatar for diafol

Way I see it, other machines must know where to find your own machine (server). If they just have the http://project.local - they won't know where to look. They must have the ip address as well. It's a "'go here' for this address".
I agree with MS, setting up a DNS would be a major overkill.

However you need to run notepad as admininstrator in order to alter hosts if UAC is enabled. The file must be edited and saved to the same location - windows won't look for it in MyDocuments for example.

@veledrom,

Let me try this one more time... I just tested this just right now, and it is working on my side.

My setup

  1. Localhost server ->xampp portable (thumb drive)
  2. Localhost OS ->windows 7 on Dell laptop

How to set up the hosts file in windows 7.
a. Click on start ==> find notepad =>right click on notepad => select run as administrator. Notepad should open up.
b. On notepad, click ==>open ==> direct file browser to ==>windows/System32/drivers/etc/ ==>if you don't see any file ==>select all files ==> select hosts file.

  1. In your host file add

    127.0.0.1 localhost
    127.0.0.1 project.local
    127.0.0.1 www.project.local

  2. Save your Changes.

  3. Open your command prompt. this should be located in acessories. On the black box, type ping project.local. You should see something like this on the black box.

    C:\Users\SomeUser>ping project.local

        Pinging project.local [127.0.0.1] with 32 bytes of data:
        Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
        Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
        Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
        Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
    
        Ping statistics for 127.0.0.1:
            Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
        Approximate round trip times in milli-seconds:
            Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
  4. Do the same for the www.project.local. The result will pretty much the as above .

Now, Open your browser and type project.local..It should take you to your local server. Do the same with the other one, type www.project.local

We are done with the host computer.

Now let's move on to the computer that will be accessing your server. This is the remote computer. My setup=> operating system =>ubuntu.

  1. Open the notepad the same way as in the instruction above.
  2. Load the hosts file and then add the following

    127.0.0.1 localhost
    192.168.1.4 project.local
    192.168.1.4 www.project.local

    1. Save changes on host file. Open the command prompt, and ping project.local and www.project.local. You should see almost the same as above. The only difference is the IP.

    2. Open the browser and type project.local. You should be able to access your server.. test the www.project.local.. it should return the same result.

    3. Do the same, for the rest of the computers accessing your server.

    I hope this helps...

Guys - Looks like there is no way of doing it without touching the client machine if human friendly domain name is required. Since adjusting host file on each client machines is a bit of pain, I'll just tell people to use IP instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.