nginx unit 使用教程

官方文档 https://unit.nginx.org/

通过 docker 安装

$ docker pull nginx/unit

$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              f7bb5701a33c        9 days ago          126MB
nginx/unit          latest              c3609c1acd08        11 days ago         236MB
hello-world         latest              fce289e99eb9        12 months ago       1.84kB

启动一个 nginx unit 容器

$ docker run -d nginx/unit
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
c386d83835f9        c3609c1acd08        "/usr/local/bin/dock…"   15 hours ago        Up 42 minutes       0.0.0.0:8001->8001/tcp   stoic_snyder

进入 nginx unit 容器

$ docker exec -it c3 /bin/bash

root@c386d83835f9:/# 

配置 nginx unit

root@ip-172-31-46-207:/# unitd --control 127.0.0.1:8000
2020/01/07 08:53:45 [info] 22#22 unit started
root@ip-172-31-46-207:/# 2020/01/07 08:53:45 [info] 24#24 discovery started
2020/01/07 08:53:45 [notice] 24#24 module: perl 5.28.1 "/usr/lib/unit/modules/perl.unit.so"
2020/01/07 08:53:45 [notice] 24#24 module: php 7.3.4-2 "/usr/lib/unit/modules/php.unit.so"
2020/01/07 08:53:45 [notice] 24#24 module: python 2.7.16 "/usr/lib/unit/modules/python2.7.unit.so"
2020/01/07 08:53:45 [notice] 24#24 module: python 3.7.3 "/usr/lib/unit/modules/python3.7.unit.so"
2020/01/07 08:53:45 [notice] 24#24 module: ruby 2.5.5 "/usr/lib/unit/modules/ruby.unit.so"
2020/01/07 08:53:45 [notice] 23#23 process 24 exited with code 0
2020/01/07 08:53:45 [info] 26#26 router started
2020/01/07 08:53:45 [info] 26#26 OpenSSL 1.1.1d  10 Sep 2019, 1010104f

root@ip-172-31-46-207:/# exit
ubuntu@ip-172-31-46-207:~/projects$ curl 127.0.0.1:8000
{
	"certificates": {},
	"config": {
		"listeners": {},
		"applications": {}
	}
}
ubuntu@ip-172-31-46-207:~/projects$ curl -X PUT -d @_projects/nginx.conf 127.0.0.1:8000
{
	"error": "Invalid method."
}
ubuntu@ip-172-31-46-207:~/projects$ curl -X PUT -d @_projects/nginx.conf 127.0.0.1:8000/config
2020/01/07 08:56:39 [info] 30#30 "pinpoint" application started
2020/01/07 08:56:39 [info] 30#30 (non ABS_MODE) php root: "/_projects/pinpoint"
{
	"success": "Reconfiguration done."
}
ubuntu@ip-172-31-46-207:~/projects$ 

修改配置

ubuntu@ip-172-31-46-207:~/projects$ cat nginx.conf 
{
    "listeners": {
        "127.0.0.1:80": {
            "pass": "applications/pinpoint"
        }
    },
    "applications": {
        "pinpoint": {
            "type": "php",
            "root": "/_projects/pinpoint",
            "index": "index.php"
        }
    }
}



ubuntu@ip-172-31-46-207:~/projects$ curl -X PUT -d @nginx.conf 127.0.0.1:8000/config
{
	"error": "Failed to apply new configuration."
}
ubuntu@ip-172-31-46-207:~/projects$ 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值