Difference between revisions of "Mini httpd"

From Alpine Linux
Jump to: navigation, search
m (Categorized: Server, Lua)
 
(3 intermediate revisions by one other user not shown)
Line 3: Line 3:
  
 
= Setup =
 
= Setup =
 +
 +
mini_httpd package is available in the Alpine Linux repositories. To install it run:
 +
{{cmd|apk add mini_httpd}}
  
 
Preparing home directory
 
Preparing home directory
Line 43: Line 46:
 
</pre>
 
</pre>
  
= Testing =
+
== 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:
 
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:
 
<pre>
 
<pre>
Line 53: Line 56:
 
curl http://localhost}}
 
curl http://localhost}}
  
= Runlevel =
+
== Adding to 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.
 
Normally you want to start the web server when the system is launching. This is done by adding mini_httpd to the needed runlevel.
 
{{Cmd|rc-update add mini_httpd default}}
 
{{Cmd|rc-update add mini_httpd default}}
Line 71: Line 74:
 
[http://haserl.sourceforge.net/ 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.
 
[http://haserl.sourceforge.net/ 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.
  
[[Mini_httpd_with_Haserl#mini_httpd_with_Haserl|Setting Up mini_httpd with Haserl]]
+
For setting up mini_httpd with Haserl, please see article [[Mini_httpd_with_Haserl|mini_httpd with Haserl]]
 +
 
 +
= mini_httpd with Haserl and Lua =
 +
[http://haserl.sourceforge.net/ 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.
 +
 
 +
[https://www.lua.org 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.
 +
 
 +
For setting up mini_httpd with Haserl and Lua, please see article [[Mini_httpd_with_Haserl_and_Lua|mini_httpd with Haserl and Lua]]
 +
 
 +
[[Category:Server]]
 +
[[Category:Lua]]

Latest revision as of 01:09, 21 September 2017

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

mini_httpd package is available in the Alpine Linux repositories. To install it run:

apk add mini_httpd

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

Adding to 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.

For setting up mini_httpd with Haserl, please see article mini_httpd with Haserl

mini_httpd with Haserl and Lua

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.

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.

For setting up mini_httpd with Haserl and Lua, please see article mini_httpd with Haserl and Lua