uhttpd是openwrt上运行一个高效小型Http服务,支持cgi, lua等特性。可以直接通过snap方式安装,如果是16.04,18.04或者20.04,snap已经默认安装了;如果是其它版本,需要先安装snap: sudo apt install snapd

然后安装:

sudo snap install uhttpd

默认80端口,为避免与apache2冲突,可以修改成其它端口,如8086:

sudo snap set uhttpd listening-port=8086

默认根目录在/var/snap/uhttpd/common,通过set方法修改好像不成功:sudo snap set uhttpd document-root-dir=/media/USB

然后通过snap命令启动即可:

$ snap run uhttpd
2021/01/03 17:24:14 Serving "/var/snap/uhttpd/common"
2021/01/03 17:24:14 Listening on ":8086"

可以在命令后面加上&号(snap run uhttpd &)以后台方式执行。

当然了,上面使用的是默认选项,也可以直接以参数指定方式修改这些默认选项,如端口、根目录等,如:uhttpd -dir=/home/user/www -addr="127.0.0.1:8080"

更多用法:

Usage of uhttpd:
-addr=":80": The ADDRESS:PORT to listen on
-dir="": The directory to serve up
-log=false: Enable/disable logging
-log-path="": Log to file (leave blank for STDOUT)
-log-prefix="uhttpd": Set the logging prefix

-addr="..." lets you set the IPv4 address and port uhttp listens on.

-dir="..." tells uhttpd which directory to serve files out of.

-log tells uhttpd to log requests for files.

-log-path="..." is an optional flag, and lets you specify the name of a file to write your request logs to. If you do not specify a log file, the request logs are written to standard output (STDOUT).

-log-prefix="..." is another optional flag, that lets you specify the logging prefix; by default, the logging prefix is "uhttpd".

More detail: https://github.com/nesv/uhttpd

最新文章

  1. Apworks框架实战(五):EasyMemo的领域模型设计
  2. Wind7外接显示器选择拓展模式后,鼠标只能往右移动才能切换到外接显示器上,不能修改切换方向
  3. 了解 Office 365
  4. editplus 替换换行 excel 表格 拼装sql语句技巧
  5. OC3_协议关键字
  6. ASP.NET中配置应用程序
  7. I2C的主机从机模拟
  8. jQuery获取select option
  9. ChildNodes详解及其兼容性处理方式
  10. 《github一天一道算法题》:插入排序
  11. Spring Boot 系列(二)单元测试&网络请求
  12. 获取对固定列不重复的新DataTable
  13. Codeforces Round #407 (Div. 1)
  14. windows 分页缓冲池 非分页缓冲池
  15. Spark集群部署(standLone)模式
  16. Linux 系统的用户和组
  17. sql server 性能调优之 资源等待 LCk
  18. mysql sql文件批量处理
  19. 微信小程序 发现之旅(三)—— 组件之间的参数传递
  20. php实现异步请求

热门文章

  1. PHP的Laravel与Composer部署项目时常见问题
  2. 【原创】浅谈指针(十二)关于static(上)
  3. Bugku CTF练习题---MISC---这是一张单纯的图片
  4. 使用CreateThreadPool创建线程池
  5. Springboot 整合 MyBatisPlus[详细过程]
  6. kernel UAF && tty_struct
  7. muduo源码分析之Buffer
  8. CVE-2021-35042
  9. JS 加载
  10. hashib加密模块、logging模块