标签:
openwrtluci |
分类: OpenWrt嵌入式 |
最近在学习OpenWrt的配置工具LuCI。
使用如下命令安装LuCI:
root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install luci
有时可能会出现安装错误或者是无意中改动了部分代码,如何相对彻底的重新安装?
使用如下命令重新安装:
root@OpenWrt:~# opkg remove luci* --autoremove
root@OpenWrt:~# opkg install luci --force-reinstall
安装后使用如下命令启动uhttpd来响应LuCI服务:
root@OpenWrt:~# /etc/init.d/uhttpd start
如果想LuCI/uhttpd开机自动启动,使用如下命令:
root@OpenWrt:~# /etc/init.d/uhttpd enable
标签:
luaopenwrtuhttpdcgilua_prefix |
分类: Lua脚本开发 |
uhttpd是OpenWrt上经常使用的、轻量级的响应http申请的web服务器,可以将申请分发给文件、CGI解释器(cgi_prefix,解释器一般为perl或者是php-cgi)或者Lua解释器(lua_prefix)。
由于使用Lua解释器开发时,由lua_handler指定的.lua文件每次修改都需要重新启动uhttpd才能生效,因此将.lua文件作为CGI脚本来调试会方便很多。
这里先以标准的Lua解释器配置为例,看uhttpd如何配置标准的lua_prefix:
编辑文件:“/etc/config/uhttpd”,将其中的:
#option lua_prefix /luci
#option lua_handler /usr/lib/lua/luci/sgi/uhttpd.lua
去掉符号“#”(即去掉注释),并修改为:
option lua_prefix /lua
option lua_handler /root/http.lua
保存退出(如果使用“vi”编辑,按ESC键,再输入“:x”,回车键即可保存退出)。
请确认存在“/root/http.lua”文件,并且其内容中包含一个名为handle_request函数,内容如下:
#!/usr/bin/lua
function handle_request(env)