nginx unit的初探
安装介绍:
https://www.oschina.net/p/nginx-unit

可以看到,unit还是很强大的,居然特么都支持go 还有python
在/etc/yum.repos.d/unit.repo加入如下语句:
# cat /etc/yum.repos.d/unit.repo [unit] name=unit repo baseurl=https://packages.nginx.org/unit/centos/$releasever/$basearch/ gpgcheck= enabled= #
makecache yum源
# yum makecache
执行安装 由于要测试unit-php,故安装unit-php ,如果要测试python,可以安装unit-python,如果要测试go,则安装unit-go
# yum install unit unit-php
这里有坑,安装unit-php的时候,默认就安装了5.3的

所以,如果你自己安装了php7的,调用phpinfo的时候,会显示php 5.3 ,原因在此,这个得需要源码安装,有点坑,过几天再去踩踩
编辑配置文件
编辑配置文件,内容如下:
# cat /etc/unit/start.json
{
"listeners": {
"*:8300": {
"application": "blogs"
}
},
"applications": {
"blogs": {
"type": "php",
,
"root": "/usr/local/nginx/php",
"index": "index.php"
}
}
}
#
启动unit并且加载json文件
# /etc/init.d/unit start
# /usr/local/bin/curl -X PUT -d @/etc/unit/start.json --unix-socket /var/run/control.unit.sock http://localhost
{
"success": "Reconfiguration done."
}
当出现success": "Reconfiguration done.则怎么加载成功,可以用netstat查看端口是否已经开起来
注意,这里有坑,如果要用curl的unix-socket参数,若curl包低于7.4需要进行升级
例如,如下安装方法:
# wget https://curl.haxx.se/download/curl-7.55.0.tar.gz ...解压,进入目录... # ./configure # make # make install
# /usr/local/bin/curl --version curl (x86_64-pc-linux-gnu) libcurl/ OpenSSL/ Release-Date: -- Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets HTTPS-proxy #
查看加载的配置
# /usr/local/bin/curl --unix-socket /var/run/control.unit.sock http://localhost
{
"listeners": {
"*:8300": {
"application": "blogs"
}
},
"applications": {
"blogs": {
"type": "php",
,
"root": "/usr/local/nginx/php",
"index": "index.php"
}
}
}
#
这时候,通过netstat可以看到8300端口已经打开了,
# cat /usr/local/nginx/php/index.php
<?php
phpinfo();
?>
#
通过8300访问,就可以看看到phpinfo的界面了,但是前提是,root下,必须有index.php哟
重新加载配置文件
重新编写配置文件
# cat /etc/unit/start.json
{
"listeners": {
"*:8300": {
"application": "blogs"
}
},
"applications": {
"blogs": {
"type": "php",
,
"root": "/usr/local/nginx/php",
"index": "index.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
}
}
}
#
重新加载配置文件
# /usr/local/bin/curl -X PUT -d @/etc/unit/start.json --unix-socket /var/run/control.unit.sock http://localhost
{
"success": "Reconfiguration done."
}
再次查看配置文件
# /usr/local/bin/curl --unix-socket /var/run/control.unit.sock http://localhost
{
"listeners": {
"*:8300": {
"application": "blogs"
}
},
"applications": {
"blogs": {
"type": "php",
,
"root": "/usr/local/nginx/php",
"index": "index.php",
"user": "php",
"group": "php",
"options": {
"file": "/usr/local/php7/lib/php.ini"
}
}
}
}
#
这时候,可以通过页面,访问如下信息:

Nginx proxy_pass设置
只需要在location中添加如下几项即可
proxy_pass http://127.0.0.1:8300; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
检查语法,重启nginx
# /usr/local/nginx/sbin/nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful # /usr/local/nginx/sbin/nginx -s reload #
通过Nginx访问界面如下:

可以看到,Server API 是unit
总结:
0.参考网址:http://unit.nginx.org/
1.unit 目前用的还很少,主流依然是php-fpm
2.如果能够采用源码编译unit的话,当然是最好的
3.curl版本问题
4.编写的json文件格式一定要正确,可以用在线工具检测json是否正确(http://www.bejson.com/)
兴趣才是最好的老师,加油吧。。。这玩意快搞了我加起来两天时间了,
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 的使用
参考文档:http://unit.nginx.org/configuration/# 安装 可以参考这两篇博客: https://www.cnblogs.com/wang-li/p/9694391.h ...
随机推荐
- leetcode56
public class Solution { public IList<Interval> Merge(IList<Interval> intervals) { var le ...
- 深度学习原理与框架-递归神经网络-RNN网络基本框架(代码?) 1.rnn.LSTMCell(生成单层LSTM) 2.rnn.DropoutWrapper(对rnn进行dropout操作) 3.tf.contrib.rnn.MultiRNNCell(堆叠多层LSTM) 4.mlstm_cell.zero_state(state初始化) 5.mlstm_cell(进行LSTM求解)
问题:LSTM的输出值output和state是否是一样的 1. rnn.LSTMCell(num_hidden, reuse=tf.get_variable_scope().reuse) # 构建 ...
- ---dd-wrt memo
http://blog.csdn.net/fyh2003/article/details/44458657http://blog.csdn.net/u010189241/article/details ...
- js 模拟css3 动画3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 使用jQuery+huandlebars遍历数组嵌套数组
兼容ie8(很实用,复制过来,仅供技术参考,更详细内容请看源地址:http://www.cnblogs.com/iyangyuan/archive/2013/12/12/3471227.html) & ...
- cdnbest站点里设置防盗链
设置需求只允许 test.kangleweb.com 访问 ,其他网站链接全部拒绝 (注:如果test.kangleweb.com是用https访问,那引用的内容地址www447.yivpn.cn也 ...
- Quartz使用
背景 很多时候,项目需要在不同时刻,执行一个或很多个不同的作业. Windows执行计划这时并不能很好的满足需求了,迫切需要一个更为强大,方便管理,集群部署的作业调度框架. 介绍 Quartz一个开源 ...
- Blender Python脚本的6个技巧
https://www.youtube.com/watch?v=vFoh3S8MLBI&index=3&list=PLw8Sjaw0TPm0J9DXj3XGi1_9fxXezlzrM ...
- JS判断手机端是否安装某应用
方法一(网页上判断) if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { var loadDateTime = new Date() ...
- Linux LVM磁盘管理
几个概念: PV:物理卷,指LVM的基本逻辑卷,包含LVM的基本参数,如/dev/sdb1等. VG:卷组,类似于非LVM的硬盘,由多个PV组成. LV:逻辑卷,类似于非LVM硬盘中的分区. PE:物 ...