Maker.io main logo

How To Set up a Website Server at Home for IoT

2019-08-07 | By Maker.io Staff

BOM

  • A PC with Windows 7 – 10
  • EasyPHP
 

Scheme-It

How To Set up a Website Server at Home for IoT

Scheme-It

HTTP vs PHP

While dashboard software can be crafted in almost any language, the use of a browser-based interface comes with a massive advantage: cross-platform capabilities. Websites, by their very nature, need to be able to serve any device with an internet browser, and any web browser that wants to be popular needs to be able to view any website. This is why HTTP is a very useful descriptive language, as it is always (or, at least, should be) interpreted the same way by any browser.

But HTTP is just the client side of a web system; it cannot, by itself, do much with active content. This is where PHP comes in – PHP is a server-side language that can be used to get entries from databases, accept connection requests, read/write files, and so much more. Just like HTTP, PHP is also cross-platform, in that any server running a PHP server can run PHP code regardless of what system was used to code it. Only the designers of the PHP server worry about making sure their software works on different platforms, and PHP coders don’t have to worry about any platform specifics.

So, in our IoT dashboard series, we will look at creating a simple IoT dashboard that can accept different IoT device connections, show a list of active devices, and display this data in chart form. But the best part of this project is that any device connected to your local area network (LAN) will be able to access the website and be “interfaceable” via a mobile device without having to learn about device specifics (such as Android and Apple). In this How-To, we will learn how to configure a Windows machine to run a simple PHP website that will act as the foundation for our own IoT dashboard!

A Pre-Requisite – Windows

We will be using a Windows-based machine to run our server. This is because Windows systems are generally easier to work with and code on, so your first step will be to find a Windows system. Luckily for us, running a website server requires very few resources and will run on most systems (if not all). This means you can use a 10-year-old laptop, a small, low-powered computer, or even your everyday PC.

Step 1 – Download EasyPHP

EasyPHP is the software that will run our website, which will be coded in PHP, HTML, and some javascript. To download EasyPHP, you can either go to the website or use the link below; however, be sure that you download the DEVSERVER and not the webserver version. The webserver version is something that would be used when your IoT project is complete and you want to use your computer as a webserver to the internet (allowing your mobile device to access it anywhere in the world). The DEVSERVER is useful for developing our IoT platform and can be accessed over LAN.

https://www.easyphp.org/save-easyphp-devserver-latest.php

Step 2 – Install and Configure DEVSERVER

When the installer has finished downloading, you will need to install EasyPHP. The installation is very trivial, and once completed, you will need to launch EasyPHP. You can check to see if EasyPHP is running by looking in the tray icon for the following symbol:

How To Set up a Website Server at Home for IoT

To open the EasyPHP dashboard, you need to right click this icon and then click Open Dashboard. Your browser should open to a website located at http://127.0.0.1:1111/index.php - if your browser shows an error, then restart EasyPHP and try again.

How To Set up a Website Server at Home for IoT

With the dashboard open, we need to configure it to use a folder of our choice as the website directory that will store our IoT platform. Therefore, in the dashboard window, click the “Add Directory” button, and in the page that appears, fill in two boxes: directory name and path. For now, we will call our Working directory name “IoT Platform,” and we will create a folder in our documents folder called “iot.”

How To Set up a Website Server at Home for IoT

The last step is to run the HTTP server, so we can run our PHP code and allow our computer to visit the website. To do this, click the start button under the HTTP Server at the top.

How To Set up a Website Server at Home for IoT

Step 3 – Test Our Server

The next step is to test our server by creating a test “index.php” file in our “iot” directory and then attempting to connect to our website. Create a blank file called “index.php” in our “iot” directory and copy and paste the following code into it:

Copy Code
<?php
	echo 'Hello, World!';
?>

To test if the site is functioning correctly, go to the EasyPHP dashboard and click the name of our project. The browser should redirect to http://127.0.0.1/edsa-IoT%20Platform/ -- if the following page shows, then our system is functioning and ready for development!

How To Set up a Website Server at Home for IoT

There are many opportunities for this server that we’ll explore in upcoming posts -- making an IoT dashboard, graphs, and even a Solar IoT panel project to cap it all off!

制造商零件编号 3405
HUZZAH32 ESP32 FEATHER LOOSE HDR
Adafruit Industries LLC
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum