1. 程式人生 > >nginx unit PHP

nginx unit PHP

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

 

未完待續.....