Mini httpd with Haserl: Difference between revisions
m (Categorized: Server, Lua) |
(use cat template, remove sudo dependencie) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:mini_httpd with Haserl}} | {{DISPLAYTITLE:mini_httpd with Haserl}} | ||
[ | [https://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 quite adequate. It implements all the basic features of an HTTP server. | ||
[ | [https://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 setup = | = mini_httpd setup = | ||
Line 12: | Line 12: | ||
You need to modify mini_httpd.conf (to add cgipat) | You need to modify mini_httpd.conf (to add cgipat) | ||
{{ | {{Cat|/etc/mini_httpd/mini_httpd.conf|## do not leave empty lines in here! | ||
#host{{=}}www.example.org | |||
## do not leave empty lines in here! | port{{=}}80 | ||
#host=www.example.org | user{{=}}minihttpd | ||
port=80 | dir{{=}}/www | ||
user=minihttpd | cgipat{{=}}**.sh|**.cgi | ||
dir=/www | |||
cgipat=**.sh|**.cgi | |||
nochroot | nochroot | ||
}} | |||
mini_httpd service should be restarted because we have changed it's configuration | mini_httpd service should be restarted because we have changed it's configuration | ||
Line 27: | Line 25: | ||
Creating sample bash script | Creating sample bash script | ||
{{ | {{Cat|/www/test.sh|#!/usr/bin/haserl | ||
#!/usr/bin/haserl | |||
content-type: text/plain | content-type: text/plain | ||
<%# This is a sample "env" script %> | <%# This is a sample "env" script %> | ||
<% env %> | <% env %> | ||
}} | |||
Setting execution permission | Setting execution permission | ||
Line 43: | Line 39: | ||
{{cmd|/www/test.sh}} | {{cmd|/www/test.sh}} | ||
{{cmd|/usr/bin/haserl /www/test.sh}} | {{cmd|/usr/bin/haserl /www/test.sh}} | ||
{{cmd| | {{cmd|su - minihttpd | ||
/usr/bin/haserl /www/test.sh}} | |||
{{cmd|apk add curl | {{cmd|apk add curl | ||
curl <nowiki>http://localhost/test.sh</nowiki>}} | curl <nowiki>http://localhost/test.sh</nowiki>}} | ||
Line 55: | Line 51: | ||
[[Mini_httpd_with_Haserl_and_Lua|mini_httpd with Haserl and Lua]] | [[Mini_httpd_with_Haserl_and_Lua|mini_httpd with Haserl and Lua]] | ||
[[Category:Server]] | [[Category:Web Server]] | ||
[[Category:Lua]] | [[Category:Lua]] |
Latest revision as of 13:58, 25 August 2023
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.
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 setup
For setting up mini_httpd please see article mini_httpd
Haserl setup
Haserl package is available in the Alpine Linux repositories. To install it run:
apk add haserl
You need to modify mini_httpd.conf (to add cgipat)
Contents of /etc/mini_httpd/mini_httpd.conf
mini_httpd service should be restarted because we have changed it's configuration
rc-service mini_httpd restart
Creating sample bash script
Contents of /www/test.sh
Setting execution permission
chmod +x /www/*.sh
Troubleshooting
For troubleshooting you can try running commands:
/www/test.sh
/usr/bin/haserl /www/test.sh
su - minihttpd /usr/bin/haserl /www/test.sh
apk add curl curl http://localhost/test.sh
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.
For setting up mini_httpd with Haserl and Lua, please, see arcticle mini_httpd with Haserl and Lua