`
阅读更多

root@router:/www# /etc/init.d/uhttpd status // 并没有status这个子命令

Syntax: /etc/init.d/uhttpd [command]

Available commands:

start Start the service

stop Stop the service

restart Restart the service

reload Reload configuration files (or restart if that fails)

enable Enable service autostart

disable Disable service autostart

root@router:/www# /etc/init.d/uhttpd reload // 重新加载配置

/etc/init.d/uhttpd //uhttpd执行脚本,该文件很值得一看

/etc/config/uhttpd // uhttpd运行相关配置

uhttpd可以同时监听多个端口

// 在/etc/config/uhttpd加入如下配置,即可通过http://ip:81/访问到/tmp目录

config 'uhttpd' 'tmp'
list 'listen_http' '0.0.0.0:81'
option 'home' '/tmp'
option 'cgi_prefix' '/cgi-bin'

root@router:/www# ls // openwrt默认端口,对应的 Root

cgi-bin cgi-bin-nodes.html cgi-bin-status.html index.html luci luci-static

root@router:/www# du -sh

325.0K .

/etc/confg/uhttpd配置中,和管理界面访问直接相关的一段配置

// 系统是怎么读取这些配置的,配置读取代码在哪个地方?

config 'uhttpd' 'main'

list 'listen_http' '0.0.0.0:80' // 默认端口设置

list 'listen_https' '0.0.0.0:443' // 通过https访问,端口设定

option 'home' '/www' // 页面所在的位置

option 'cert' '/etc/uhttpd.crt' // https访问对应的证书

option 'key' '/etc/uhttpd.key' // 和上面的cert有什么关系?

option 'cgi_prefix' '/cgi-bin' //

option 'script_timeout' '60'

option 'network_timeout' '30'

option 'tcp_keepalive' '1'

option 'rfc1918_filter' '0'

listen_http 只给定端口,则同时绑定IPV4和IPV6地址. :port只绑定IPV4, ::port,同时绑定IPV6.

home 根目录

key 私钥

crt 公钥

cgi_prefix 定义了CGI脚本的前缀,该前缀相对应home路径,如果该字段为空,则cgi功能失效。

lua_prefix 将请求转发给内置的Lua解析器,如果为空,则Lua功能失效。

cgi-bin目录下有多个脚本,这些配置和uhttpd的实现紧密相关?

root@router:/www# ls cgi-bin -l

-rwxr-xr-x 1 root root 135 Sep 16 2008 luci

-rwxr-xr-x 1 root root 2384 Dec 12 01:08 olsr-viz.sh

drwxr-xr-x 2 root root 32 Apr 2 11:26 splash

-rwxr-xr-x 1 root root 1432 Dec 12 01:08 vizdata.sh

CGI: Perl CGI, PHP CGI, Lua CGI ...

参考资料

http://news.netcraft.com/archives/2011/04/06/april-2011-web-server-survey.html

https://forum.openwrt.org/search.php?search_id=1586996754

http://wiki.openwrt.org/doc/uci/uhttpd

http://wiki.openwrt.org/doc/howto/http.overview

http://en.wikipedia.org/wiki/Comparison_of_lightweight_web_servers 各种web服务器之比较

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics