2018-12-26 14:20:33 星期三
第一步: 安装, 我用的是centos 6 官网 http://unit.nginx.org/installation/#centos-packages
第二步: 启动 如果是按照官网, 通过yum 进行安装的, 启动方法就是
/usr/sbin/unitd --control 127.0.0.1:8224
2018/12/26 14:26:11 [info] 13924#13924 unit started
此时
ps -ef | grep unit root 13777 1 0 14:03 ? 00:00:00 unit: main v1.7 [/usr/sbin/unitd --control 127.0.0.1:8224] nobody 13779 13777 0 14:03 ? 00:00:00 unit: controller nobody 13896 13777 0 14:14 ? 00:00:00 unit: router
第三步: 创建配置文件 , 复制并修改官网的json, 创建json文件: /etc/unit/test.json
{ "listeners": { "*:8300": { "application": "test" } }, "applications": { "test": { "type": "php", "processes": 2, "root": "/www/unit/test", "index": "index.php" } } }
第四步: 用curl命令将这个json文件发送给unit, 创建对象 (注意官网是通过 unix-socket 进程间通信的方法去发送json配置文件给unit的守护进程的, 在这里直接发送到unit监听的端口)
curl -X PUT -d @/etc/unit/test.json http://localhost:8224/config
此时多了两个application进程:
ps -ef | grep unit root 13925 1 0 14:26 ? 00:00:00 unit: main v1.7 [/usr/sbin/unitd] nobody 13927 13925 0 14:26 ? 00:00:00 unit: controller nobody 13928 13925 0 14:26 ? 00:00:00 unit: router root 13929 13925 0 14:26 ? 00:00:00 unit: "test" application root 13930 13925 0 14:26 ? 00:00:00 unit: "test" application
第五步: 查看已发送的配置
curl http://127.0.0.1:8224
第六步: 更改json配置文件, 进程数设置为5, 并重新发送配置, 再查看进程数: application进程变为5个
ps -ef | grep unit root 13983 1 0 14:48 ? 00:00:00 unit: main v1.7 [/usr/sbin/unitd --control 127.0.0.1:8224] nobody 13985 13983 0 14:48 ? 00:00:00 unit: controller nobody 13986 13983 0 14:48 ? 00:00:00 unit: router root 13993 13983 0 14:49 ? 00:00:00 unit: "test" application root 13994 13983 0 14:49 ? 00:00:00 unit: "test" application root 13995 13983 0 14:49 ? 00:00:00 unit: "test" application root 13996 13983 0 14:49 ? 00:00:00 unit: "test" application root 13997 13983 0 14:49 ? 00:00:00 unit: "test" application
未完待续.....