<article class="baidu_pl">
<div id="article_content" class="article_content clearfix">
<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-044f2cf1dc.css">
<div id="content_views" class="markdown_views prism-tomorrow-night">
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
</svg>
<p>本文介绍了如何管理和配置uhttpd服务,包括启动、停止、重启和重新加载配置文件。通过修改/uetc/config/uhttpd配置,可以监听多个端口,并允许通过http://ip:81/访问到特定目录。此外,还提到了CGI脚本的配置,如cgi_prefix和lua_prefix,以及/home、/key和/crt选项的作用。提供了多个相关脚本和资源链接供进一步学习。<br> root@router:/www# /etc/init.d/uhttpd status // 并没有status这个子命令</p>
<p><a href="https://so.csdn.net/so/search?q=Syntax&spm=1001.2101.3001.7020" target="_blank" class="hl hl-1" rel="noopener noreferrer">Syntax</a>: /etc/init.d/uhttpd [command]</p>
<p>Available commands:</p>
<p> start Start the service</p>
<p> stop Stop the service</p>
<p> restart Restart the service</p>
<p> reload Reload <a href="https://so.csdn.net/so/search?q=configuration&spm=1001.2101.3001.7020" target="_blank" class="hl hl-1" rel="noopener noreferrer">configuration</a> files (or restart if that fails)</p>
<p> enable Enable service autostart</p>
<p> disable Disable service autostart</p>
<p> </p>
<p>root@router:/www# /etc/init.d/uhttpd reload // 重新加载配置</p>
<p>/etc/init.d/uhttpd // uhttpd执行脚本,该文件很值得一看</p>
<p>/etc/config/uhttpd // uhttpd运行相关配置</p>
<p> </p>
<p>uhttpd可以同时监听多个端口</p>
<p>// 在/etc/config/uhttpd加入如下配置,即可通过<a href="http://ip:81/" rel="nofollow">http://ip:81/</a>访问到/tmp目录</p>
<p>config 'uhttpd' 'tmp' <br> list 'listen_http' '0.0.0.0:81'<br> option 'home' '/tmp'<br> option 'cgi_prefix' '/cgi-bin'</p>
<p> </p>
<p> </p>
<p>root@router:/www# ls // openwrt默认端口,对应的 Root</p>
<p>cgi-bin cgi-bin-nodes.html cgi-bin-status.html index.html luci luci-static</p>
<p>root@router:/www# du -sh</p>
<p>325.0K .</p>
<p> </p>
<p>/etc/confg/uhttpd配置中,和管理界面访问直接相关的一段配置</p>
<p>// 系统是怎么读取这些配置的,配置读取代码在哪个地方?</p>
<p> </p>
<p>config 'uhttpd' 'main'</p>
<p> list 'listen_http' '0.0.0.0:80' // 默认端口设置</p>
<p> list 'listen_https' '0.0.0.0:443' // 通过https访问,端口设定</p>
<p> option 'home' '/www' // 页面所在的位置</p>
<p> option 'cert' '/etc/uhttpd.crt' // https访问对应的证书</p>
<p> option 'key' '/etc/uhttpd.key' // 和上面的cert有什么关系?</p>
<p> option 'cgi_prefix' '/cgi-bin' //</p>
<p> option 'script_timeout' '60'</p>
<p> option 'network_timeout' '30' </p>
<p> option 'tcp_keepalive' '1'</p>
<p> option 'rfc1918_filter' '0'</p>
<p> </p>
<p>listen_http 只给定端口,则同时绑定IPV4和IPV6地址. :port只绑定IPV4, ::port,同时绑定IPV6.</p>
<p>home 根目录</p>
<p>key 私钥</p>
<p>crt 公钥</p>
<p>cgi_prefix 定义了CGI脚本的前缀,该前缀相对应home路径,如果该字段为空,则cgi功能失效。</p>
<p>lua_prefix 将请求转发给内置的Lua解析器,如果为空,则Lua功能失效。</p>
<p> </p>
<p>cgi-bin目录下有多个脚本,这些配置和uhttpd的实现紧密相关?</p>
<p> </p>
<p>root@router:/www# ls cgi-bin -l</p>
<p>-rwxr-xr-x 1 root root 135 Sep 16 2008 luci</p>
<p>-rwxr-xr-x 1 root root 2384 Dec 12 01:08 olsr-viz.sh</p>
<p>drwxr-xr-x 2 root root 32 Apr 2 11:26 splash</p>
<p>-rwxr-xr-x 1 root root 1432 Dec 12 01:08 vizdata.sh</p>
<p> </p>
<p>CGI: Perl CGI, PHP CGI, Lua CGI ...</p>
<p> </p>
<p> </p>
<p>参考资料</p>
<p>http://news.netcraft.com/archives/2011/04/06/april-2011-web-server-survey.html</p>
<p>https://forum.openwrt.org/search.php?search_id=1586996754</p>
<p>http://wiki.openwrt.org/doc/uci/uhttpd</p>
<p>http://wiki.openwrt.org/doc/howto/http.overview</p>
<p>http://en.wikipedia.org/wiki/Comparison_of_lightweight_web_servers 各种web服务器之比较</p>
<p> </p>
<div>
<div></div>
</div>
</div><div><div></div></div>
<link href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/markdown_views-f23dff6052.css" rel="stylesheet">
<link href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/style-c216769e99.css" rel="stylesheet">
</div>
<div id="treeSkill" style="display: block;"><div class="skill-tree-box"><div class="skill-tree-head">文章知识点与官方知识档案匹配,可进一步学习相关知识</div><div class="skill-tree-body"><div class="skill-tree-item"><span class="skill-tree-href"><a data-report-click="{"spm":"1001.2101.3001.6866","dest":"https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog"}" href="https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog" target="_blank">CS入门技能树</a><i></i><a data-report-click="{"spm":"1001.2101.3001.6866","dest":"https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog"}" href="https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog" target="_blank">Linux入门</a><i></i><a data-report-click="{"spm":"1001.2101.3001.6866","dest":"https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog"}" href="https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog" target="_blank">初识Linux</a></span><span class="skill-tree-con"><span class="skill-tree-count">41865</span> 人正在系统学习中</span></div></div></div></div>
</article>
08-05
07-21
07-01
05-11