What is a web server good for?Web servers are those computers on the World Wide Web that provide content that can then be accessed using a browser. This text, which is currently being displayed on your screen, is stored as a file on such a computer, also known as a server. To call this file, you either entered the address of my server (which is unlikely, because I don't know it by heart), or you followed a so-called hyperlink (short: link) (which is more likely). The web pages that can be called are stored on the web server in Hypertext Markup Language format. These are text files that can contain special commands. A link is such a command that redirects you to another website as soon as you click on it.
In order for a computer to operate as a web server, appropriate software must be installed, that can interpret all the necessary commands that you (mostly without being aware of) send in order to be able to view a page. The most common software of this type is the Apache web server, the source code of which is maintained by the Apache Software Foundation and made freely available to everyone.
Remote control via WWWAs soon as more than one computer is required to implement a project, these computing servants have to communicate with each other. Handling this communication with the help of the Hypertext Transfer Protocol via web servers simplifies the necessary coding work for two reasons:
(1) One can access an existing, global infrastructure.
Installing ApacheThe installation instructions described here refer to RaspiOS and thus apply to almost all operating systems based on Debian Linux.
In the example I assume that the Raspberry Pi OS with desktop is installed (Lite can cause problems). It is strongly recommended to perform a fresh installation if problems occur while following the instructions on this page.
Switching a GPIO via a web serverNext, a GPIO will be switched via a Python script. I use the example from the chapter Python: Switching GPIOs. The script needs minor changes, because the web server expects certain lines to be printed in plain text at the beginning and at the end of the script:
"It doesn't work!"...is, as told before, no statement suitable to get any help! Each installation step of the Apache web server outputs a message. Please read these messages through, because that's what the programmers wrote the messages for! Search the internet for these error messages and you will find Gigabytes of help. If everything (apparently) went smoothly during the installation, but it still does not work, the browser displays an error that can help finding the cause of error. Even better are the error messages, the web server generates in it's log file:
The messages stored in this file are especially helpful if you want to ask someone for help. For simple problems this can be done via leaving a comment on this page. For trickier problems you should read how you can get in touch with me in my column contact.
"It works!" is a statement that needs no further explanation, but makes me always happy to read.
... and anyone who would like to thank me in particular for these instructions or any kind of help can make a donation to give me a boost in motivation for creating more of such chapters - many thanks to all backers that already sent me an obol!
...if the LED flashes, everything is installed correctly. The Apache web server runs smoothly even on a Raspberry Pi Model B+. I called the script with a smartphone - no "app" is required, a simple browser is sufficient.