Chinaunix首页 | 论坛 | 博客
  • 博客访问: 127248
  • 博文数量: 40
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 236
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-04 09:56
个人简介

小小博客,不足为外人道

文章分类

全部博文(40)

分类: Web开发

2015-01-06 16:54:45

uhttpd使用[1]

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 ...
阅读(3256) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~