Jan Kneschke maintains lighttpd and posted a simple FCGI for lua. This magnet.c should be easily compiled with

1
gcc -Wall -O2 -g -o magnet magnet.c -llua5.1 -lfcgi -ldl -lm

This may not work if your lua-include is not in the path for compiling.

And you'll run into such error messages:

1
2
3
4
5
magnet.c:3:20: error: lualib.h: No such file or directory
magnet.c:4:21: error: lauxlib.h: No such file or directory
magnet.c:11: Error: expected »)« before »*« token
magnet.c:19: Error: expected »)« before »*« token
magnet.c:59: Error: expected »)« before »*« token

Since you may not be used to compiling, I think it might be good to post a reason for that and a solution.

The reason is, that lualib.h is not in include path. To add it specific folder for the compiling to the include path you may use the -I /path/name/ parameter.

1
gcc -Wall -O2 -g -o magnet magnet.c -I/usr/include/lua5.1/ -llua5.1 -lfcgi -ldl -lm

There are some distributions, where the -llua5.1 may not work and result in cannot find -llua5.1. In this cases try -llua instead.

Have fun compiling!