5

I need to find a very compact, cross-platform web server that can run Lua scripts, ie. either a regular web server like Mongoose that will forward queries to a Lua program in eg. FastCGI, or a web server itself written in Lua which will save the need to provide a separate web server.

I recently started learning about Lua so am still in the dark about what is available out there, save for the two I came across:

If someone's already done this recently, what solution would you recommend along with any tutorial/article that would get me started?

arserbin3
  • 6,010
  • 8
  • 36
  • 52
Gulbahar
  • 5,343
  • 20
  • 70
  • 93
  • See also here: http://stackoverflow.com/questions/1166684/what-web-server-to-use-for-lua-web-development/1181803#1181803 – Alexander Gladysh May 19 '10 at 12:00
  • Thanks Alexander. I haven't found documentation on how to install Xavante. If I still can't get this working, I'll check out Haserl, since it seems equally light-weight and supports Lua. – Gulbahar May 19 '10 at 12:08
  • 1
    The coming version of Apache supports Lua out of the box: http://httpd.apache.org/docs/trunk/mod/mod_lua.html – ulrichb May 20 '10 at 07:02
  • Good to know, although Apache is quite heavy compared to Mongoose. I only need a basic HTTP server to forward SQL queries to SQLite, and send back the data. Thanks for tip. – Gulbahar May 20 '10 at 16:36

8 Answers8

3

There's also a new project from Zed Shaw called mongrel2 that has Lua support via another project (also by Zed) called Tir, bound to mongrel2 via a ZeroMQ bus. (mongrel2.org, tir.mongrel2.org). It's not as mature as the Lua nginx project but it does provide for dedicated Lua processes and significant advantages for logical and physical separation of application components. Cool stuff.

2

Mongoose now supports Lua out of the box. If you're using windows, Lua support is pre-compiled in the binary. Checkout the example at https://raw.github.com/valenok/mongoose/master/examples/lua/dirscan.lp

valenok
  • 827
  • 7
  • 9
2

Why not try Xavante, the Lua-oriented web server built by the Kepler project, which is run by many of the same people who brought us Lua?

user1461607
  • 2,416
  • 1
  • 25
  • 23
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
  • I haven't found how to install Xavante yet. Can it run without installing the whole Lua SDK? – Gulbahar May 19 '10 at 11:38
  • For lack of a better word, I meant, the packages found at http://luabinaries.luaforge.net/ and http://code.google.com/p/luaforwindows/ – Gulbahar May 19 '10 at 12:29
1

There's also lighttpd.

lhf
  • 70,581
  • 9
  • 108
  • 149
  • Apparently, Lighttpd supports Lua but only for mod_madgnet, as the equivalent to Apache's mod_rewrite. I don't know 1) if that's true, and if yes, 2) what the (dis)advantages are compared to a full-fledged FastCGI alternative. – Gulbahar May 19 '10 at 11:43
  • The lighthttpd is not suitable for generating page content with Lua (script execution blocks whole server process, AFAIR). It is intended to control server logic. – Alexander Gladysh May 19 '10 at 12:04
  • Yup, so I'd rather use a web server that's already written in Lua or, alternatively, a good way to run a Lua script as FastCGI that will be called by a language-agnostic web server. – Gulbahar May 19 '10 at 12:30
0

Nginx and Apache have both a Lua module, and Apache supports CGI. Try Ophal, a Lua web framework that runs on Nginx, Apache, Lighty and any other web server that supports CGI/FastCGI.

You can also take a look at G-WAN, which is very compact and ultra fast.

develCuy
  • 576
  • 5
  • 14
0

I have not tried this myself, but there is a blog post about using Lua with nginx here.

A good and informative question btw, I hadn't heard of Haserl before :)

ponzao
  • 20,684
  • 3
  • 41
  • 58
0

Try llserver - minimalistic Lua server. Runs as single coroutine, serves dynamic content via callback function: https://github.com/ncp1402/llserver

user2053898
  • 479
  • 1
  • 5
  • 8
0

I would recommend redbean, an open source single-file distributable web server that runs on six operating systems (and weight less than an average web-page).

redbean embeds Lua, SQLite, and MbedTLS into a fork() driven application server that benchmarks at 1.1 million qps on a personal computer. […] This makes redbean a great fit for when you want to build an app that's vertically integrated into a single tiny file that runs on nearly all PCs and servers.


The web is doom: The Average Webpage Is Now the Size of the Original Doom (~2.4MiB)

bufh
  • 3,153
  • 31
  • 36