How to enable local network users to access my WAMP sites?

418,024

Solution 1

See the end of this post for how to do this in WAMPServer 3

For WampServer 2.5 and previous versions

WAMPServer is designed to be a single seat developers tool. Apache is therefore configure by default to only allow access from the PC running the server i.e. localhost or 127.0.0.1 or ::1

But as it is a full version of Apache all you need is a little knowledge of the server you are using.

The simple ( hammer to crack a nut ) way is to use the 'Put Online' wampmanager menu option.

left click wampmanager icon -> Put Online

This however tells Apache it can accept connections from any ip address in the universe. That's not a problem as long as you have not port forwarded port 80 on your router, or never ever will attempt to in the future.

The more sensible way is to edit the httpd.conf file ( again using the wampmanager menu's ) and change the Apache access security manually.

left click wampmanager icon -> Apache -> httpd.conf

This launches the httpd.conf file in notepad.

Look for this section of this file

<Directory "d:/wamp/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
#    Require all granted
#   onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost
</Directory>

Now assuming your local network subnet uses the address range 192.168.0.?

Add this line after Allow from localhost

Allow from 192.168.0

This will tell Apache that it is allowed to be accessed from any ip address on that subnet. Of course you will need to check that your router is set to use the 192.168.0 range.

This is simply done by entering this command from a command window ipconfig and looking at the line labeled IPv4 Address. you then use the first 3 sections of the address you see in there.

For example if yours looked like this:-

IPv4 Address. . . . . . . . . . . : 192.168.2.11

You would use

Allow from 192.168.2

UPDATE for Apache 2.4 users

Of course if you are using Apache 2.4 the syntax for this has changed.

You should replace ALL of this section :

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost

With this, using the new Apache 2.4 syntax

Require local
Require ip 192.168.0

You should not just add this into httpd.conf it must be a replace.

For WAMPServer 3 and above

In WAMPServer 3 there is a Virtual Host defined by default. Therefore the above suggestions do not work. You no longer need to make ANY amendments to the httpd.conf file. You should leave it exactly as you find it.

Instead, leave the server OFFLINE as this funtionality is defunct and no longer works, which is why the Online/Offline menu has become optional and turned off by default.

Now you should edit the \wamp\bin\apache\apache{version}\conf\extra\httpd-vhosts.conf file. In WAMPServer3.0.6 and above there is actually a menu that will open this file in your editor

left click wampmanager -> Apache -> httpd-vhost.conf

just like the one that has always existsed that edits your httpd.conf file.

It should look like this if you have not added any of your own Virtual Hosts

#
# Virtual Hosts
#

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot c:/wamp/www
    <Directory  "c:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

Now simply change the Require parameter to suite your needs EG

If you want to allow access from anywhere replace Require local with

Require all granted

If you want to be more specific and secure and only allow ip addresses within your subnet add access rights like this to allow any PC in your subnet

Require local
Require ip 192.168.1

Or to be even more specific

Require local
Require ip 192.168.1.100
Require ip 192.168.1.101

Solution 2

You must have the Apache process (httpd.exe) allowed through firewall (recommended).

Or disable your firewall on LAN (just to test, not recommended).

Example with Wamp (with Apache activated):

  1. Check if Wamp is published locally if it is, continue;
  2. Access Control Panel
  3. Click "Firewall"
  4. Click "Allow app through firewall"
  5. Click "Allow some app"
  6. Find and choose C:/wamp64/bin/apache2/bin/httpd.exe
  7. Restart Wamp

Now open the browser in another host of your network and access your Apache server by IP (e.g. 192.168.0.5). You can discover your local host IP by typing ipconfig on your command prompt.

It works

Solution 3

go to... 
C:\wamp\alias

Inside alias folder you will see some files like phpmyadmin,phpsysinfo,etc...

open each file, and you can see inside file some commented instruction are give to access from outside ,like to give access to phpmyadmin from outside replace the lines

Require local

by

Require all granted

Solution 4

What finally worked for me is what I found here:

http://www.codeproject.com/Tips/395286/How-to-Access-WAMP-Server-in-LAN-or-WAN

To summarize:

  • set Listen in httpd.conf:

    Listen 192.168.1.154:8081

  • Add Allow from all to this section:

    <Directory "cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory>

  • Set an inbound port rule. I think the was the crucial missing part for me:

Great! The next step is to open port (8081) of the server such that everyone can access your server. This depends on which OS you are using. Like if you are using Windows Vista, then follow the below steps.

Open Control Panel >> System and Security >> Windows Firewall then click on “Advance Setting” and then select “Inbound Rules” from the left panel and then click on “Add Rule…”. Select “PORT” as an option from the list and then in the next screen select “TCP” protocol and enter port number “8081” under “Specific local port” then click on the ”Next” button and select “Allow the Connection” and then give the general name and description to this port and click Done.

Now you are done with PORT opening as well.

Next is “Restart All Services” of WAMP and access your machine in LAN or WAN.

Solution 5

For years I've been using WAMP with number of vhosts, and all worked fine from the WAMP machine.

Few days ago I needed to test one of the sites from other computers on the LAN before publishing it on-line.

Here is my set-up, mostly based on answers/comments in this post:

  • all site hosted in the WAMP server have a "domain" .local (mydomain*.com => mydomain*.local)
  • for all sites http traffic is redirected to https

The following changes were needed to make it work for all LAN computers

  1. httpd.conf - no changes, and it is not necessary to put WAMP Online
  2. For all vhosts in the Directory section of httpd-vhosts.conf (and httpd-ssl.conf for https enabled sites)
#Require local
#Require all granted # also works
#Allow from all # works for all LAN
Allow from 192.168.55.*
  1. Enable httpd.exe in Windows Firewall
  2. Set DNS records for every mydomain*.local in hosts file on every computer in the LAN

192.168.55.221 mydomain*.local

192.168.55.221 being the address of the WAMP server. If you have local DNS server like I do (Pi-hole), you can do it there.

Update If any device in the LAN uses VPN, and DNS server address is set at the router, DNS server approach will not work for those devices. You have to set DNS record in the host file!

This set-up works with every Win PC, tablet/phone, and Win VMs on VMWare. Strangely, it doesn't work with Ubuntu 20.04 (on VMWare and on Raspberry PI4B). I guess I have to learn how to set-up DNS on Ubuntu!

Share:
418,024
Ezeewei
Author by

Ezeewei

Updated on October 15, 2021

Comments

  • Ezeewei
    Ezeewei over 2 years

    First of all, I read at least 20 articles about this topic, and not one of them can match up the scenario and I screwed up the process numerous times. So I turn help by offering my specific scenario if any help will be appreciated.

    Laptops or other devices are connected through a wireless router.

    I've tried:

    • Enable Port 80 on firewall. nothing happened.
    • Run ping, ipconfig and tried IPv4 address there, denied access or bring me to verizon (my ISP), router config page.
    • Tried config Apache, was a mess, never get all the authorization setup in numerous posts and tried one of promising one, which crashed my WAMP, have to went through all the trouble and reinstall.

    What I really tried to accomplish is really simply allow all users connect to that wireless router be able to acces my Win8 hosted WAMP sites.

    I wonder if there is any specific steps that I can walk through to make it really work?

    WAMP 2.4 on Win8.1. Laptop host local sites.

  • Ezeewei
    Ezeewei almost 10 years
    One problem. I have various local sites (i.e. 192.168.1.1/mysite1) but once I tried on my phone to access that website, its appear incomplete for some reason. Its a wordpress site. Would you know the reason for it to happen?
  • Ezeewei
    Ezeewei almost 10 years
    Oh, I found the issue, because in DB, that links are base on localhost! everything work perfect now : D
  • Mai
    Mai about 9 years
    So, how can I let ALL users in the network access to the device with wamp server running? How can I write the IP Address in that configuration? I am using DHCP.
  • RiggsFolly
    RiggsFolly about 9 years
    If you mean any ip address in your subnet then like I said in the above question use the frist 3 quartiles of the ip address
  • KillABug
    KillABug about 9 years
    Allow from seems to be deprecated in the latest version of apache i.e 2.4.The substitute as I check the documentation is Require,but I tried Require Host 192.168.1 and Require ip 192.168.1 and it does not allow me to access over the network!
  • RiggsFolly
    RiggsFolly about 9 years
    @Mai You should set the PC that runs WAMPServer to be a Static IP that is not in the range of ip addresses used by your routers DHCP server,
  • Mai
    Mai about 9 years
    @RiggsFolly Well, I am using DHCP server because I am using Wi-Fi connection. There is less problem for me if the IP is dynamic. What I did is to use ipconfig at the command prompt every time the PC running WAMPServer gets connected to the Wi-Fi network. If I am letting ALL users inside the network to access to the PC, I used your first solution of your answer. Your comment can work. I can apply it if there are lot of users/devices accessing to localhost. Why I am doing this because I need to test my website to the smart phones and other devices.
  • RiggsFolly
    RiggsFolly about 9 years
    @Mai There would be less to do if you just lookup how to set a static ip for the WAMPServer machine See how to here
  • KillABug
    KillABug about 9 years
    @RiggsFolly Hey thanks,actually I had tried the same,but the issue was with my firewall blocking traffic from network. Cheers
  • gegobyte
    gegobyte almost 9 years
    @RiggsFolly There is no "Order Deny,Allow Deny from all Allow from 127.0.0.1 Allow from ::1 Allow from localhost" in my httpd.conf file
  • RiggsFolly
    RiggsFolly almost 9 years
    @ChinmaySarupria Then you probably have Apache 2.4 so read the syntax for that after the Apache 2.2 syntax?!?!?!?
  • gegobyte
    gegobyte almost 9 years
    @RiggsFolly I have done that but still it doesn't works. 403 Forbidden.
  • CodyBugstein
    CodyBugstein over 8 years
    In which file did you do this?
  • Mark Manning
    Mark Manning over 8 years
    In the Apache httpd.conf file for most of the changes and the host file that is in the Windows/System32 directory (on XP). An update to the above is required. You actually can have multiple LISTEN commands in the httpd.conf file. So you actually can have: Listen localhost:80 and Listen 192.168.78.234:80 One after the other.
  • Mark Manning
    Mark Manning over 8 years
    I decided to update my answer on the TCP/IP changes.
  • Charlesliam
    Charlesliam over 8 years
    192.168.1.154 stands for?
  • CodyBugstein
    CodyBugstein over 8 years
    @Charlesliam the other machine's ip address
  • Matteus Barbosa
    Matteus Barbosa almost 8 years
    Make sure your Wamp server is running and you have already set it available with "Put Online"
  • chirag satapara
    chirag satapara about 7 years
    @RiggsFolly , it is not work for me in wampserver 3.0.6 , can you help me to solve this ASAP
  • chirag satapara
    chirag satapara about 7 years
    @RiggsFolly, this is my httpd-vhosts.conf file ... static.spiceworks.com/attachments/post/0017/3795/… , but it is not allow to acces using my ip address
  • chirag satapara
    chirag satapara about 7 years
    and this is my dictory in httpd.conf file. // <Directory /> AllowOverride none # Require all granted # onlineoffline tag - don't remove Order Deny,Allow # Deny from all Allow from all Allow from 127.0.0.1 Allow from ::1 Allow from localhost Allow from 192.168.1.112 </Directory> //
  • RiggsFolly
    RiggsFolly about 7 years
    Why did you alter httpd.conf file, you no longer need to. And why have to use Apache 2.2 syntax when you are using Apache 2.4
  • chirag satapara
    chirag satapara about 7 years
    what should i do in httpd.conf file ?
  • chirag satapara
    chirag satapara about 7 years
  • Matteus Barbosa
    Matteus Barbosa over 6 years
    Clear the browser cache may solve some problems as well
  • Pretty Cool
    Pretty Cool over 6 years
    Firewall part helped me for Windows 10. Thanks!
  • Pawel
    Pawel about 5 years
    I already had the Windows Firewall disabled so I didn't think this would work - but adding Apache as an exception did in fact work for me. Thanks!
  • Matteus Barbosa
    Matteus Barbosa about 5 years
    @Pawel this does not make sense since a disabled firewall ignores the exception tables and allow everything. Make sure your antivirus software is disabled or it's firewall layer is also disabled to perform a clean test.
  • garek007
    garek007 almost 5 years
    @RiggsFolly I followed the instructions here (I'm on wamp 3) and I'm able to type in 192.168.0.12/myproject. I get a listing of files instead of the virtualhost serving the site. My site actually lives in the /public folder, but the project folder is one level up. What did I do wrong?
  • RiggsFolly
    RiggsFolly almost 5 years
    This may help you with that @garek007
  • garek007
    garek007 almost 5 years
    @RiggsFolly thanks I got my site loading with SSL, but chrome warns me. I have to pick advanced option, then proceed with risk, and then site shows as not secure. so now I have a certificate problem.
  • Halil İbrahim Oymacı
    Halil İbrahim Oymacı almost 4 years
    To run my new virtulhost from other PCs in same LAN, I also needed to add ` Require local` and Require ip 192.168.1 to virtualhost: localhost. (new virtualhost also has that parameters). Otherwise browser says access denied to new virtualhost.
  • RiggsFolly
    RiggsFolly almost 4 years
    @HalilİbrahimOymacı No you dont. If you had to do that, then something else is wrong somewhere