mini_httpd

From Alpine Linux
Revision as of 14:53, 22 November 2016 by Slukin (talk | contribs) (Created page with "{{DISPLAYTITLE:mini_httpd}} [http://acme.com/software/mini_httpd/ mini_httpd] is a small HTTP server. Its performance is not great, but for low or medium traffic sites it's qu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

mini_httpd is a small HTTP server. Its performance is not great, but for low or medium traffic sites it's quite adequate. It implements all the basic features of an HTTP server.

Setup

Preparing home directory

mkdir /www chown minihttpd /www

Before writing your configuration perhaps you may wish to backup original configuration file

mv /etc/mini_httpd/mini_httpd.conf /etc/mini_httpd/mini_httpd.conf.orig

Creating mini_httpd configuration file

vi /etc/mini_httpd/mini_httpd.conf

## do not leave empty lines in here!
#host=www.example.org
port=80
user=minihttpd
dir=/www
nochroot

Creating sample .html file

vi /www/index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>HTML5</title>
</head>
<body>
    Server is online
</body>
</html>

Starting mini_httpd

rc-service mini_httpd start

 * Starting mini_httpd ...                                               [ ok ]

Testing

This section is assuming that mini_httpd is running and sample html page "/www/index.html" is created. Launch a web browser and point it to your web server. You should get:

Server is online

You can also test web server with curl

apk add curl curl http://localhost

Runlevel

Normally you want to start the web server when the system is launching. This is done by adding mini_httpd to the needed runlevel.

rc-update add mini_httpd default

Now mini_httpd should start automatically when you launch your system next time. To test that run:

reboot

To make sure that mini_httpd is started run:

ps aux | grep mini_httpd

You should get something like this:

  580 minihttp   0:00 /usr/sbin/mini_httpd -i /var/run/mini_httpd/mini_httpd.pid -C /etc/mini_httpd/mini_httpd.conf -l /var/log/mini_httpd/mini_httpd.log

mini_httpd with Haserl

Haserl is a small program that uses shell or Lua script to create cgi web scripts. It is intended for environments where PHP or ruby are too big.

Setting Up mini_httpd with Haserl

mini_httpd with Haserl and Lua

Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.

Setting Up mini_httpd with Haserl and Lua