openwrt uci 命令设置nginx

简介#

还是喜欢用nginx,比httpd功能全一些,openwrt也有nginx。简单安装即可。

但是它默认设置是uci.conf,且不可直接编辑,需要UCI命令来控制。

本文就介绍如何使用uci命令来设置openwrt 的 nginx。

官方说明:[OpenWrt Wiki] Nginx webserver

本文主要讨论更改openwrt中nginx的默认设置。

一:安装nginx#

opkg update && opkg install nginx-ssl 

二:uci命令基础#

复制代码
Usage: uci [<options>] <command> [<arguments>]

Commands:
        batch
        export     [<config>]
        import     [<config>]
        changes    [<config>]
        commit     [<config>]
        add        <config> <section-type>
        add_list   <config>.<section>.<option>=<string>
        del_list   <config>.<section>.<option>=<string>
        show       [<config>[.<section>[.<option>]]]
        get        <config>.<section>[.<option>]
        set        <config>.<section>[.<option>]=<value>
        delete     <config>[.<section>[[.<option>][=<id>]]]
        rename     <config>.<section>[.<option>]=<name>
        revert     <config>[.<section>[.<option>]]
        reorder    <config>.<section>=<position>

Options:
        -c <path>  set the search path for config files (default: /etc/config)
        -d <str>   set the delimiter for list values in uci show
        -f <file>  use <file> as input instead of stdin
        -m         when importing, merge data into an existing package
        -n         name unnamed sections on export (default)
        -N         don't name unnamed sections
        -p <path>  add a search path for config change files
        -P <path>  add a search path for config change files and use as default
        -t <path>  set save path for config change files
        -q         quiet mode (don't print error messages)
        -s         force strict mode (stop on parser errors, default)
        -S         disable strict mode
        -X         do not use extended syntax on 'show'
复制代码

三:检查配置show#

 uci show nginx

四:增加监听端口add_list#

80 443都被封禁了,所以我将更改监听18080  18443端口,这两个端口必改。

五:提交配置重启nginx#

uci commit

/etc/init.d/nginx reload

service nginx restart

cat /etc/nginx/uci.conf

 

/etc/init.d/nginx reload

service nginx restart

这是两种openwrt 管理服务的方法,init.d 或 service。

六:其他配置#

/etc/nginx/uci.conf.template

 

 这里是http部分的设置了。每次reload的时候,是从这个模板来生成的,改size,log_format,就在这里改了。

改玩reload restart,就可以了。

 #

作者:上官飞鸿

出处:https://www.cnblogs.com/jackadam/p/18442647

版权:本作品采用「知识共享-署名-非商业性-禁止演绎(CC-BY-NC-ND)」许可协议进行许可。

posted @   上官飞鸿  阅读(633)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
历史上的今天:
2018-10-01 sqlalchemy 获取表结构。
more_horiz
keyboard_arrow_up light_mode palette
选择主题
menu
点击右上角即可分享
微信分享提示