nginx unit 的使用
参考文档:http://unit.nginx.org/configuration/#
安装
可以参考这两篇博客:
https://www.cnblogs.com/wang-li/p/9694391.html
https://www.cnblogs.com/wang-li/p/9684040.html
启动unit
$
启动的方式有两种,一种是control.unit.sock方式,还有一种就是如上方式了
加载unit配置
先来看看json文件吧,我们需要加载这个文件
$ cat /usr/local/unit/script/www.json
{
"listeners": {
"*:8300": {
"application": "blogs"
},
"*:8310": {
"application": "phpsite"
}
},
"applications": {
"blogs": {
"type": "php7",
,
"root": "/usr/local/nginx/php",
"index": "index.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
},
"phpsite": {
"type": "php7",
,
"root": "/usr/local/nginx/php",
"index": "info.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
}
}
}
$
利用curl加载josn文件至unit
$ sudo curl -X PUT -d@/usr/local/unit/script/www.json '127.0.0.1:8400/config'
{
"success": "Reconfiguration done."
}
$
如果返回"success": "Reconfiguration done.",则就加载完毕
可以查看一下端口
$ netstat -tulnp | [-]. (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0.0.0.0:* LISTEN - tcp 0.0.0.0:* LISTEN - tcp 0.0.0.0:* LISTEN - $
其中,8400是我们启动unit程序的时候,作为的控制unit API的端口,而8300,8310是在json中编写完毕的,用于监听php的
显示unit配置
显示完整配置
$ curl http://127.0.0.1:8400
{
"config": {
"listeners": {
"*:8300": {
"application": "blogs"
},
"*:8310": {
"application": "phpsite"
}
},
"applications": {
"blogs": {
"type": "php7",
,
"root": "/usr/local/nginx/php",
"index": "index.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
},
"phpsite": {
"type": "php7",
,
"root": "/usr/local/nginx/php",
"index": "info.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
}
}
}
}
$
显示部分配置
$ curl 'http://127.0.0.1:8400/config/applications/blogs'
{
"type": "php7",
,
"root": "/usr/local/nginx/php",
"index": "index.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
}
$
如果现在去访问8300 和 8310端口的话,会得到两种信息,8300会返回index.php的内容,而8310会返回info.php的内容
利用curl修改unit配置
修改listeners的application
$ curl -X PUT -d '"blogs"' '127.0.0.1:8400/config/listeners/*:8310/application'
{
"success": "Reconfiguration done."
}
$
查看修改后的信息
$ curl '127.0.0.1:8400/config/listeners'
{
"*:8300": {
"application": "blogs"
},
"*:8310": {
"application": "blogs"
}
}
$
可见,8310的application已经由最初的phpsite修改为现在的blogs
修改phpsite的首页文件为index.php
$ curl -X PUT -d '"index.php"' '127.0.0.1:8400/config/applications/phpsite/index'
{
"success": "Reconfiguration done."
}
$
查看修改后的信息
$ curl '127.0.0.1:8400/config/applications'
{
"blogs": {
"type": "php7",
,
"root": "/usr/local/nginx/php",
"index": "index.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
},
"phpsite": {
"type": "php7",
,
"root": "/usr/local/nginx/php",
"index": "index.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
}
}
$
可见,phpsite的index已经由当初的info.php变为现在的index.php了
不过,这个配置重新加载json文件后,又会按照文件内容进行改变了,所以,如果想下次加载文件后依然保持这个值的话,需要修改json文件才行
利用curl删除unit对象
现在想删除unit phpsited对象
$ curl -X DELETE '127.0.0.1:8400/config/listeners/*:8310'
{
"success": "Reconfiguration done."
}
$ curl -X DELETE '127.0.0.1:8400/config/applications/phpsite'
{
"success": "Reconfiguration done."
}
$
查看现在的unit配置
$ curl '127.0.0.1:8400'
{
"config": {
"listeners": {
"*:8300": {
"application": "blogs"
}
},
"applications": {
"blogs": {
"type": "php7",
,
"root": "/usr/local/nginx/php",
"index": "index.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
}
}
}
}
$
现在来看的话,配置就只有blogs配置了
其实后面还有一大堆的东西,比如ssl,全局设置等等,还包括,go和python设置等等...
nginx unit 的使用的更多相关文章
- svn + nginx unit + python3自动化发布web服务方法
本周将python web服务管理更换成nginx unit以后发现接口性能有了明显的提升,访问速度快了不少.不过有个很大的问题就是使用svn自动化发布以后,服务并没有刷新使用新的代码运行,而又不懂得 ...
- 关于nginx unit服务非正常关闭后,无法重新启动问题的处理
昨天在前领导技术大牛吕哥的帮忙下,python服务管理从nginx+supervisor+uwsgi+python3改为了轻便结构nginx + unit + python3,部署和配置起来顿时轻松起 ...
- nginx unit PHP
2018-12-26 14:20:33 星期三 综述: nginx unit php 的关系: nginx -> 转发请求到 8300端口 -> unit 转发 8300 收到的请求 -& ...
- Nginx unit 源码安装初体验
Nginx unit 源码安装初体验 上次介绍了从yum的安装方法(https://www.cnblogs.com/wang-li/p/9684040.html),这次将介绍源码安装,目前最新版为1. ...
- nginx unit nodejs 模块试用(续)
最新(应该是18 年了)nginx unit 发布了新的版本,对于nodejs 的支持有很大的改进,上次测试过,问题还是 比较多,这次使用新版本在测试下对于nodejs 的支持,以及以前block ...
- nginx unit nodejs 模块试用
unit 对于nodejs 的支持是在10.25 发布的,基本能用,但是依然有好多问题,当前在测试的时候就发现,请求之后会block , 相关的issue 已经有人反馈了,最好使用源码编译,方便测 ...
- nginx Unit 服务器
转自: https://github.com/nginx/unit/pull/18/ 感谢: https://www.v2ex.com/t/389528 English 简体中文 繁體中文 NGINX ...
- nginx unit java 试用
unit 当前已经支持java了,当时支持基于servlet 的开发模式,以下是一个简单的学习 基于官方的demo 环境准备 docker-compose文件 version: "3&q ...
- nginx unit的初探
安装介绍: https://www.oschina.net/p/nginx-unit 可以看到,unit还是很强大的,居然特么都支持go 还有python 在/etc/yum.repos.d/unit ...
随机推荐
- kubernetes学习笔记之七: Ingress-nginx 部署使用
一.Ingress 简介 在Kubernetes中,服务和Pod的IP地址仅可以在集群网络内部使用,对于集群外的应用是不可见的.为了使外部的应用能够访问集群内的服务,在Kubernetes 目前 提供 ...
- cxf+spring+restful简单接口搭建
之前都是用soap协议搭建,最近学了下restful,以便日后翻阅,小生才疏学浅,不足之处请多见谅. 1.maven配置 <project xmlns="http://maven.ap ...
- 204. jetcache:在Spring Boot中怎么玩?
[视频&交流平台] àSpringBoot视频:http://t.cn/R3QepWG à SpringCloud视频:http://t.cn/R3QeRZc à Spring Boot源 ...
- 《算法导论》——顺序统计RandomizedSelect
RandomizedSelect.h: #include <stdlib.h> namespace dksl { /* *交换 */ void Swap(int* numArray,int ...
- spring cloud整合 websocket 的那些事
我们知道, 现在很多浏览器都已经是直接支持 websocket 协议的了, 除此之外, sockjs, 也可以实现 websocket 功能.. 当然, 其原理是不同的. 一开始 websocket ...
- Android单元测试学习(一)
什么是单元测试 首先总结一下什么是单元测试,单元测试中的单元在Android或Java中可以理解为某个类中的某一个方法,因此单元测试就是针对Android或Java中某个类中的某一个方法中的逻辑代码进 ...
- mysql timestamp字段定义的
Cause: java.sql.SQLException: Cannot convert value '2017-07-26 20:40:41.000000' from column 10 to TI ...
- PHP 调试打印输出变量
var_dump ($row); echo "hello"; echo "\n"; print_r ($arr); php 数组 对象 $arr = json_ ...
- windows下Mysql8.0.12安装详解
MySQL的安装过程还是比较繁琐,为了以后安装节约时间,将其详细安装过程总结如下: 1>下载对应版本 下载地址:https://dev.mysql.com/downloads/mysql/ 2& ...
- 【原】The Linux Command Line - Workiing with commands
● type – Indicate how a command name is interpreted● which – Display which executable program will b ...