5

I have configured a Wamp server in my local network and it works great. I can access each project with xxx.xxx.xxx/myproject, but, as another option, can I configure them to access like www.myproject.com or http://myproject.com from the local network? I am an embedded system programmer and I have to access my embedded Ethernet boards with various machines. It works fine with an IP address, but I just want to know if it is possible.

Brendon Shaw
  • 297
  • 5
  • 21
Saneesh A T
  • 365
  • 1
  • 6
  • 12

3 Answers3

5

you can do that by configuring your virtual hosts and the httpd.conf file of your apache

configure apache

the file of your apache will be located in:

  • c:\wamp\Apache2\conf\httpd.conf

search for something like:

DocumentRoot 'c:/wamp/www'

and add the following code after the DocumentRoot 'c:/wamp/www' into the file:

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
    ServerName localhost
    DocumentRoot 'C:\wamp\www'
</VirtualHost>
<VirtualHost 127.0.0.1>
    ServerName yourdomain.com
    DocumentRoot 'C:\wamp\www\ClientsMyClient'
</VirtualHost>

configure hostfile

on mac via terminal:

  • sudo nano /etc/hosts

on windows 7:

  • open a texteditor as administrator
  • open file and go to: %Systemroot%\System32\Drivers\Etc

(source: edit hosts file in windows 7)

when you have it opened just write a new line into the file:

XXX.XXX.XXX yourdomain.com
(mostly this will be: 127.0.0.1 yourdomain.com)

I do suggest you use yourdomain.local, because if you ever host a website, you might get confused about which one is the public one and which one is the local website :).

in your browser you then type: yourdomain.com and you should be able to have a project hosted on a wamp server, with his own domain.

hope this helps! :-)

(source: http://viralpatel.net/blogs/how-to-setup-multiple-virtual-hosts-in-wamp/)

Bananam00n
  • 814
  • 9
  • 27
0

Open C:\Windows\system32\drivers\etc\hosts and after that localhost address(127.0.0.1) add the domain name which you want like www.example.com and make a space between ip address and domain name.

For Example, 127.0.0.1 www.example.com

Note: You need to open 'hosts' file in Administrator Privileges .

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
nazim10
  • 129
  • 3
0
  1. Open C:\wamp64\bin\apache\apache2.4.46\conf\httpd.conf

  2. Search for something like:

    #Virtual hosts
    #Include conf/extra/httpd-vhosts.conf
  1. Uncomment line
    Include conf/extra/httpd-vhosts.conf
  1. Open C:\wamp64\bin\apache\apache2.4.46\conf\extra\httpd-vhosts.conf

  2. Add the following code in the end:

    <VirtualHost *:80>
        ServerName yourdomain.com
        ServerAlias yourdomain.com
        DocumentRoot "c:/wamp64/www/somename"
        <Directory  "c:/wamp64/www/somename/">
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require local
        </Directory>
    </VirtualHost>
  1. Go to: C:\Windows\System32\Drivers\Etc
  2. Open hosts
  3. When you have it opened just write a new line into the file:
    127.0.0.1 yourdomain.com
  1. Restart WAMP server

  2. In your browser you then type: yourdomain.com and you should be able to have a project hosted on a wamp server, with his own domain.