Set up a local web server

The most efficient way to test dynamic content is through a local web server. If you want to know how to set one up, you’ve come to the right place.

In this article, we’ll show you how to set up a local web server for different operating systems and test a successful installation.

To work

A local web server is essentially set up by installing software on your computer to give these web server capabilities; it is ‘local’ as you are responsible for managing it. We’ll show you how to turn your computer into an HTTP server, usually based on installing Apache software. But first, here are some requirements:

  • A special computer to become your server
  • With Windows or Linux or a Mac computer with macOS
  • An internet connection
  • Dual Core 2GHz or higher
  • 4GB RAM
  • 1 GB of free disk space.

Set up a local web server on a Windows 10 PC

Windows 10 is not Unix based, so we install XAMPP, which is a combination of Apache, MySQL and PHP. To install XAMPP, do the following:

  1. Navigate to XAMPP and proceed to install the Windows version.
    Screenshot 12 18
  2. Run the installer when prompted.
  3. Select “Apache” to install only a web server.
  4. Once the installation is complete, click “Finish” to open the XAMPP Control Panel.

To confirm a successful installation, enter “127.0.0.1” or “localhost” in the address bar of your web browser. The XAMPP configuration page should appear.

Set up a local web server on a Mac

MacOS has the Apache web server pre-installed; to enable it, do the following:

  1. Click on “Finder”.
    1 39
  2. Click “Applications” > “Utilities”, double click “Terminal”.
    2 34
  3. Now enter and run this command to enable Apache:
    sudo apachectl start
    3 25
  4. To confirm Apache is running, enter “127.0.0.1” or “localhost” in the address bar of your web browser. You might get a “It works!” message.
    4 22

How to set up a local web server on Ubuntu?

To install Apache Web Server on Ubuntu Linux 18.04, follow these steps:

  1. Open a terminal and enter the command:
    sudo apt-get install apache2
  2. Confirm the installation and sit back with Apache installed.
  3. To confirm that the installation was successful, enter the following into the address bar of a web browser:
    https://local.server.ip
    • In the web browser you should see the Apache2 Ubuntu Default page.

Set up a local web server on a Linux device

  1. Go to a terminal for Debian and Ubuntu/Ubuntu based distro and enter the command:
    sudo apt install apache2
    • For CentOS and Red Hat, enter the command:
    sudo dnf install httpd
  2. To confirm that the installation was successful, enter “localhost” or “127.0.0.1” in your web browser.
    • The Apache default welcome page should display “It Works”.

Set up a LAN web server

We now show you how to set up a LAN network that connects to the Internet via Windows. First of all you need the following:

  • a computer (server)
  • a network switch
  • broadband connection
  • a router (with built-in modem)
  • the devices you want to connect to the network
  • Ethernet cables

Connect your first computer:

Connect your router or network switch to the computer with an Ethernet cable, and then turn it on. If you are setting up for the first time, the “Set up a network” wizard will do it for you automatically. If it doesn’t appear, do the following:

  1. Click “Network and Sharing Center” in the “Control Panel” or “Settings”.
    Screenshot 2 34
  2. Select ‘Set up a new connection or network’.
    Screenshot 3 29
    • Follow the instructions on the screen.

Configure your Wi-Fi:

If you want to connect your devices to your network wirelessly, you need to set up Wi-Fi; if not, you can use ethernet cables.

Follow the instructions in your router/network switch manual to enable Wi-Fi. To make it as safe as possible, do the following:

  • Consider changing the default SSID (network name), Wi-Fi login and password. This can be done by logging into your router, through the network settings, or a web browser on your PC.
  • Make sure to choose the most advanced security protection – currently it is WPA2.
  • For the changes to take effect now, restart your PC.

Connect your LAN to the Internet:

For your LAN web access, connect your router and modem to the headphone line through the WAN port.

Connect your devices to the LAN:

Whether you have connected your devices to the LAN via Wi-Fi or Ethernet cable, do the following:

  • Enable WiFi on your devices
    Screenshot 6 25
  • Select your network
    Screenshot 7 25
  • Enter your new password when prompted
    Screenshot 8 19

To connect to your LAN using Ethernet cables:

  • Connect the cable to your network switch/router
  • Connect the other end to your device
  • Do the same for your other device[s]you can access it from any device on your LAN.

Start sharing now:

To set up a “HomeGroup” for sharing resources over your network, do the following:

  1. Navigate to “Control Panel” > “Network and Internet” > “HomeGroup”.
  2. Select “Create a homegroup” and the homegroup setup wizard will start and give you the password needed to allow the other devices to connect to the LAN.

There are several ways to share and access resources in a LAN, including:

  • Right click on files or folders > “Share with…”
  • Add files to public folders and enable “Public Folder Sharing” through the Network and Sharing Center.

Set up a local HTTP server

Now we will show you how to set up a local web server for testing. For a Python installation on Windows, do the following:

  1. Navigate to the Python home page python.org.
    Screenshot 9 20
  2. In the “Download” section, select the Python “3.xxx” link.
    Screenshot 11 19
  3. At the bottom of the screen, select the “Windows x86” exe file to download.
  4. Run the file when it is downloaded.
  5. From the first page, make sure to check the “Add Python 3.xxx to PATH” checkbox.
  6. Select “Install” and then “Close” when you’re done.
  7. Open Command Prompt and enter this command to check for a successful installation:
    1. python -V
    2. # Or you may have command py available,
    3. # in that case attempt py -V

This will display the version. If the number is correct, type the following “cd” command and then in the folder where your sample is located:

  1. # add the directory name to enter, e.g.
  2. cd Desktop
  3. # use two dots to go up a directory level if necessary

cd ..

Now enter the following commands to start the server in the directory:

  1. # If the Python version displayed is more than 3.X
  2. python3 -m http.server
  3. # In windows as an alternative enter “python” to substitute “py -3”, or “python3”
  4. # If Python version 2.X is displayed

python -m SimpleHTTPServer

To see a list of the contents in the directory, from the address bar of your web browser, go to the server and enter “localhost:8000

If port 8000 is already occupied, use another port, for example:

  • python3 -m http.server 7800 (Python 3.x) or
  • python -m SimpleHTTPServer 7800 (Python 2.x)

Then enter “localhost:7800” to access the server.

Additional FAQs

What is a LAN?

A LAN (Local Area Network) connects a collection of devices in one area, for example in a house, office floor or building. The size of a LAN can range from thousands of users and devices to just one user.

What is a WAN?

A WAN (wide area network) connects telecommunications geographically. It is most commonly used by government agencies, schools and businesses to pass data to each other so that people can perform their functions regardless of their physical location.

From a regular computer to a powerful web server

Local web servers are great for hosting websites and storing just about anything you want others to access. With software packages that magically turn your regular PC or computer into a web server, setting one up is pretty easy.

Now that we’ve shown you how to set up your own server, could you get your web server up and running? What kind of things do you use your web server for? We’d love to hear from you, leave a comment in the section below.

Leave a Reply

Your email address will not be published. Required fields are marked *