lua转换成html,教程二 网页和lua交互修改openwrt

硬件

fe82431197596f75361a5865997e3333.png

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

bbd3b44d5bbc56d1b140359401d1e7d8.png

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登陆路由器文件系统

187e697a7dcd28aaf0b9bed356015db2.png

标签:cgi,教程,http,lighttpd,uhttpd,lua,openwrt,mod

来源: https://www.cnblogs.com/kekeoutlook/p/10791736.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值