Fast and safe with the Hiawatha secure web server
Service Warehouse
The next thing Hiawatha needs to know is which website to serve up. To define the website, you first specify the subdirectory with the files. Apache users will be familiar with this directory as DocumentRoot, but Hiawatha calls it WebsiteRoot:
WebsiteRoot = /usr/local/var/www/hiawatha
In principle, you can select any folder on your disk; you will find a sample index.html file below /usr/local/var/www/hiawatha. Hiawatha needs the name (or alternatively the IP address) on which the website will be accessible:
Hostname = www.mywebsite.com
This detail is particularly important if you are using virtual hosts (see the box titled "Virtual Hosts" for more details). If you use IPv6 addresses, just use them; you can even mix them with IPv4 addresses.
That's it. This minimal configuration contains just six lines. Listing 1 is a complete httpd.conf file. Comments start with a pound sign, as in shell scripts.
Listing 1
Minimal Configuration for Hiawatha
Kick Starter
Just to see whether the configuration is working, launch the web server with the following command:
sudo hiawatha
If you receive an error message:
Error binding IP_address
either Hiawatha does not have sufficient privileges (for ports below 1024) or a competing web server is already listening on the same port. A competing web server is actually a common occurrence if you are using a distribution that comes with a pre-configured web server, such as Apache. In that case, you can either change the port or stop the competitor. To stop Apache in Ubuntu, for example, you could enter the command
sudo /etc/init.d/apache2 stop
although you might still see an error message:
Warning: can't write PID file /usr/local/var/run/hiawatha.pid
The preceding message says that Hiawatha does not have access privileges for the /usr/local/var/run directory; one common cause for this message is that the directory just doesn't exist. You can either create the directory manually or live with the error message for the time being. The web server simply stores its process ID in the specified PID file. Alternatively, you can use httpd.conf to point to a different file location:
PIDFile=<filename>
Launching a browser and pointing to localhost will tell you if Hiawatha is running properly. You should see the test page shown in Figure 1.
A kill signal, as in
<C>sudo killall hiawatha<C>
will stop Hiawatha. Of course, this is a fairly brutal approach, and it is not very elegant if you are thinking of adding the web server startup to your distribution's boot process. The hiawatha script included in the extras subdirectory below the source code directory gives you a more elegant approach to launching and stopping Hiawatha, but you should be aware of a couple of obstacles. First, the script assumes that the web server was able to create the PID file. Also, the script is designed for Debian. If you want to run the script on any other distribution, you need to modify the paths in the first four lines to match your local conditions.
Going Walkabout
As you would expect of a modern web server in these Web 2.0 times, Hiawatha supports the execution of CGI programs. Of course, the administrator first has to explicitly enable this feature
ExecuteCGI = yes
and then specify which file suffix the CGI programs will have:
CGIextension = cgi
In the case of scripts, such as PHP or Python applications, Hiawatha also needs the name and path for the interpreter:
CGIhandler = /usr/bin/php5-cgi:php,php5
When Hiawatha finds a file with a .php or .php5 suffix, it will launch the php5-cgi interpreter in the /usr/bin folder and pass the script in to it. The same approach is used for other script languages:
CGIhandler = /usr/bin/perl:pl CGIhandler = /usr/bin/python:py
To prevent buggy or malicious CGI programs or scripts from crashing or hijacking the computer, you should restrict their run time. A value of five seconds should do for a start:
TimeForCGI = 5
« Previous 1 2 3 4 Next »
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.