【无标题】

<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&amp;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>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;start &nbsp; Start the service</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;stop &nbsp; &nbsp;Stop the service</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;restart Restart the service</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;reload &nbsp;Reload <a href="https://so.csdn.net/so/search?q=configuration&amp;spm=1001.2101.3001.7020" target="_blank" class="hl hl-1" rel="noopener noreferrer">configuration</a> files (or restart if that fails)</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;enable &nbsp;Enable service autostart</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;disable Disable service autostart</p> 
<p>&nbsp;</p> 
<p>root@router:/www# /etc/init.d/uhttpd reload &nbsp;// 重新加载配置</p> 
<p>/etc/init.d/uhttpd &nbsp;//&nbsp;uhttpd执行脚本,该文件很值得一看</p> 
<p>/etc/config/uhttpd // uhttpd运行相关配置</p> 
<p>&nbsp;</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'&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; list 'listen_http' '0.0.0.0:81'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; option 'home' '/tmp'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; option 'cgi_prefix' '/cgi-bin'</p> 
<p>&nbsp;</p> 
<p>&nbsp;</p> 
<p>root@router:/www# ls &nbsp;// openwrt默认端口,对应的 Root</p> 
<p>cgi-bin &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cgi-bin-nodes.html &nbsp; cgi-bin-status.html &nbsp;index.html &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; luci &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; luci-static</p> 
<p>root@router:/www# du -sh</p> 
<p>325.0K &nbsp;.</p> 
<p>&nbsp;</p> 
<p>/etc/confg/uhttpd配置中,和管理界面访问直接相关的一段配置</p> 
<p>// 系统是怎么读取这些配置的,配置读取代码在哪个地方?</p> 
<p>&nbsp;</p> 
<p>config 'uhttpd' 'main'</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;list 'listen_http' '0.0.0.0:80' &nbsp; &nbsp; &nbsp;// 默认端口设置</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;list 'listen_https' '0.0.0.0:443' &nbsp;// 通过https访问,端口设定</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;option 'home' '/www' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 页面所在的位置</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;option 'cert' '/etc/uhttpd.crt' &nbsp; &nbsp;// https访问对应的证书</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;option 'key' '/etc/uhttpd.key' &nbsp; // 和上面的cert有什么关系?</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;option 'cgi_prefix' '/cgi-bin' &nbsp; &nbsp; &nbsp;//</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;option 'script_timeout' '60'</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;option 'network_timeout' '30' &nbsp;</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;option 'tcp_keepalive' '1'</p> 
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;option 'rfc1918_filter' '0'</p> 
<p>&nbsp;</p> 
<p>listen_http &nbsp;只给定端口,则同时绑定IPV4和IPV6地址. :port只绑定IPV4, ::port,同时绑定IPV6.</p> 
<p>home 根目录</p> 
<p>key &nbsp; &nbsp;私钥</p> 
<p>crt &nbsp; &nbsp; 公钥</p> 
<p>cgi_prefix &nbsp;定义了CGI脚本的前缀,该前缀相对应home路径,如果该字段为空,则cgi功能失效。</p> 
<p>lua_prefix &nbsp;将请求转发给内置的Lua解析器,如果为空,则Lua功能失效。</p> 
<p>&nbsp;</p> 
<p>cgi-bin目录下有多个脚本,这些配置和uhttpd的实现紧密相关?</p> 
<p>&nbsp;</p> 
<p>root@router:/www# ls cgi-bin -l</p> 
<p>-rwxr-xr-x &nbsp; &nbsp;1 root &nbsp; &nbsp; root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;135 Sep 16 &nbsp;2008 luci</p> 
<p>-rwxr-xr-x &nbsp; &nbsp;1 root &nbsp; &nbsp; root &nbsp; &nbsp; &nbsp; &nbsp; 2384 Dec 12 01:08 olsr-viz.sh</p> 
<p>drwxr-xr-x &nbsp; &nbsp;2 root &nbsp; &nbsp; root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 32 Apr &nbsp;2 11:26 splash</p> 
<p>-rwxr-xr-x &nbsp; &nbsp;1 root &nbsp; &nbsp; root &nbsp; &nbsp; &nbsp; &nbsp; 1432 Dec 12 01:08 vizdata.sh</p> 
<p>&nbsp;</p> 
<p>CGI: Perl CGI, PHP CGI, Lua CGI ...</p> 
<p>&nbsp;</p> 
<p>&nbsp;</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 &nbsp;各种web服务器之比较</p> 
<p>&nbsp;</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="{&quot;spm&quot;:&quot;1001.2101.3001.6866&quot;,&quot;dest&quot;:&quot;https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog&quot;}" 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="{&quot;spm&quot;:&quot;1001.2101.3001.6866&quot;,&quot;dest&quot;:&quot;https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog&quot;}" 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="{&quot;spm&quot;:&quot;1001.2101.3001.6866&quot;,&quot;dest&quot;:&quot;https://edu.csdn.net/skill/gml/gml-1c31834f07b04bcc9c5dff5baaa6680c?utm_source=csdn_ai_skill_tree_blog&quot;}" 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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值