硬件
GL-iNet
1 首先安装 webserver之lighttpd ,openwrt自带的是uhttpd
1-1安装过程简略
1-2配置
Lighttpd默认页面
写lighttpd的配置文件lighttpd.conf。
(1)使用语句 server.modules = ("mod_cgi")加入 cgi 模块;
(2)使用语句 cgi.assign = (".cgi" => "") 设置 cgi模块的扩展名和解释器。就本语句而言,表示cgi模块的扩展名是“.cgi”且该 cgi模块不需要特别的解释器来执行
lighttpd configuration
修改文件 /etc/lighttpd/lighttpd.conf in:
server.modules = (
"mod_access",
"mod_cgi",
"mod_alias",
"mod_accesslog",
"mod_compress",
)
and add these lines:
$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = ( "" => "" )
}
cgi.assign = (
".cgi" => ""
)
Restart lighttpd typing:
debarm:~# /etc/init.d/lighttpd restart
2 编写登陆网页
http://192.168.8.1/cgi-bin/webservice?wifi-key=xixi&wifi-key-msg=xx
3 编写lua脚本文件执行修改
3-2 lua解析http参数
3-3 lua调用shell脚本命令,使用uci接口交互修改。
安装uhttpd包(https需要加装“uhttpd-mod-tls”和“px5g”);
修改uhttpd配置文件“/etc/config/uhttpd”,将Lua作为“interpreter”;
Lua脚本写到“/www/cgi-bin/”目录下,但是不带扩展名,且可执行;
Fast-CGI要求Lua脚本必须首先使用“io.write()”输出“Content-type: text/html\n\n”;
“/www/cgi-bin/”目录下的脚本可以调用“/usr/lib/lua/”目录下的自定义模块;
Lua环境已经就绪。
1登陆路由器文件系统
标签:cgi,教程,http,lighttpd,uhttpd,lua,openwrt,mod
来源: https://www.cnblogs.com/kekeoutlook/p/10791736.html