Compiling/configuring Mongoose to run Lua scripts?

227 views
Skip to first unread message

Gilles

unread,
Jan 3, 2014, 5:14:42 PM1/3/14
to mongoos...@googlegroups.com
Hello

I'd like to run small Lua web scripts on an ARM9E appliance running Debian. It looks like Mongoose is the simplest way, but the relevant page about Lua in the Overview section is currently 404.

Could someone show me how to compile and configure Mongoose to run a "Hello, world!" Lua script securely on that platform?

Thank you.

Sergey Lyubka

unread,
Jan 3, 2014, 5:17:33 PM1/3/14
to mongoose-users
Fixed broken link, thanks for pointing it out.
The easiest way to compile mongoose on Linux with Lua support is
to close git tree, then

cd /path/to/mongoose/repo/build
make mongoose-lua



--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.

Gilles

unread,
Jan 4, 2014, 5:40:12 AM1/4/14
to mongoos...@googlegroups.com
Thanks Sergey.

The tarball from the Downloads section doesn't seem to include the mongoose-lua Makefile, and I don't know Git.

To avoid having to go through a whole tutorial just for this, is there a howto that shows how to compile Mongoose with support for Lua (and SQLite)?

Thank you.

Sergey Lyubka

unread,
Jan 4, 2014, 7:14:12 AM1/4/14
to mongoose-users
What OS are you using?

Gilles

unread,
Jan 4, 2014, 5:49:15 PM1/4/14
to mongoos...@googlegroups.com
# cat /proc/cpuinfo
Processor       : Feroceon 88FR131 rev 1 (v5l)
BogoMIPS        : 1191.11
Features        : swp half thumb fastmult edsp
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant     : 0x2
CPU part        : 0x131
CPU revision    : 1

Hardware        : Marvell SheevaPlug Reference Board
Revision        : 0000
Serial          : 0000000000000000

# cat /proc/version
Linux version 3.2.0-4-kirkwood (debian...@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 Debian 3.2.51-1

# uname -a
Linux sheevaplug 3.2.0-4-kirkwood #1 Debian 3.2.51-1 armv5tel GNU/Linux

# cat /etc/issue
Debian GNU/Linux 7 \n \l

Sergey Lyubka

unread,
Jan 4, 2014, 6:52:15 PM1/4/14
to mongoose-users
$ sudo apt-get install git
$ cd mongoose/build
$ make mongoose-lua

Gilles

unread,
Jan 4, 2014, 7:50:50 PM1/4/14
to mongoos...@googlegroups.com
Thanks, it compiled and runs OK.

BTW, the page is 404 again:

I assume Mongoose includes the Lua interpreter, so I don't need to use the " -cgi_interpreter" switch. However, after adding the following "test.lp" file and launching "mongoose-lua -cgi_pattern **.lp", the browser displays the source code instead of showing the output:

<? print('HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n') ?>
<html>
<body>
<p>
 
<span>Today is:</span>
 
<? mg.write(os.date("%A")) ?>
</p>
</body>
</html>

Sergey Lyubka

unread,
Jan 4, 2014, 8:52:38 PM1/4/14
to mongoose-users
With newest sources, use .mg.lua extension. Don't specify -cgi_interpreter.

Gilles

unread,
Jan 5, 2014, 10:52:42 AM1/5/14
to mongoos...@googlegroups.com
Thanks, the sample could run the first lines (mg.write).

However, no SQLite database is created, and "./mongoose-lua -error_log_file mongoose.error.log" doesn't create a log file so I could check why:

/tmp/mongoose/build# cat test.mg.lua


mg
.write('HTTP/1.0 200 OK\r\n', 'Content-Type: text/plain\r\n', '\r\n')


mg
.write(os.date("%A"))


local db = sqlite3.open('requests.db')


db
:exec([[


  CREATE TABLE IF NOT EXISTS requests
(


    id INTEGER PRIMARY KEY AUTOINCREMENT
,


    timestamp NOT NULL
,


    method NOT NULL
,


    uri NOT NULL
,


    addr


 
);


]])


db
:close()
Is

Do I need to recompile Mongoose with a different Makefile than "mongoose-lua" to include both the Lua interpreter and the SQLite DBMS?

Also, is
http://cesanta.com/#docs,Mongoose.md the only documentation available at this time?

Sergey Lyubka

unread,
Jan 5, 2014, 11:02:12 AM1/5/14
to mongoose-users
Do I need to recompile Mongoose with a different Makefile than "mongoose-lua" to include both the Lua interpreter and the SQLite DBMS?


Ah, please use another target to build with sqlite:

$ make mongoose-lua-sqlite

 
Also, is http://cesanta.com/#docs,Mongoose.md the only documentation available at this time?

Hmm, could you elaborate please? There are many pages of documentation on various topics,
listed on the left hand side. What exactly are you looking for?
 
Reply all
Reply to author
Forward
0 new messages