How to Host a Website on a Local Server and access the website by workstations on the LAN

by Ebuka John Onyejegbu

Hello All, Welcome Back,

In my previous article i explained how i was able to set up a simple wireless LAN, but that wasn’t the final aim of the project i executed.

The aim was to host a website on a server connected to the LAN and enable all other workstations on same LAN to access the website by simply inputting the server’s IP Address.

For the server: i already have a high spec laptop i wanted to use, i have WAMP SERVER installed on it with with the website in the htdocs folder. so i can access the website by entering http://localhost  or  http://127.0.0.1  if you need a tutorial on how to set up a local server you can click here. Also i chose the IP Address to assign to this server to be the next IP After my access point IP, although this doesn’t matter.

Next, i needed to make the website accessible by other workstations on the LAN, by default WAMP is for development purpose so wont permit access from other workstations on a network without some tweaking.

STEP 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; you can open this in Notepad++ or any code editor you have.

STEP 2: Look out for the Directory tag <Directory> it may be under your vhost tag depending on your Apache Version.

<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
     Allow from 192.168.0.0
</Directory>

My WAMP is running Apache v2.5 but if your Apache is v2.4

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.0

You should not just add this into httpd.conf it must be a replace. according to this stack post

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

STEP 3: After that go ahead and access the IP address of the server on the other workstations connected to the LAN.

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy