CGI默认在/www/cgi-bin文件中,创建一个新的CGI程序helloCGI。代码如下
#!/usr/bin/lua
-- HTTP header
print("Content-Type: text/html")
print("") -- An empty line
-- body
print("<h1>Hello CGI</h1>")
print("<h2>Current time: " .. os.date("%D %T") .. "</h2")
更改权限
chmod +x /www/cgi-bin/helloCGI
浏览http://<OpenWrt’ IP Address>/cgi-bin/helloCGI
即可看到结果
通过html跳转到CGI
在/etc/config/uhttpd
中新增一个端口配置
config uhttpd 'ServerName'
option home '/www/tmp/'
list listen_http '0.0.0.0:8080