やっつけ不定記

好きなときに好きなことをちゃっちゃと書いてます

NGINX Unit

NGINX Unitがバージョン1.0になったということで、
午後くらいから試してます。
とりあえず、Atomic Host上にCentOS 7のDocker環境を整えて
NGINX Unitのインストールまでは行ったのですが、
サンプルをベースに作成したJSONが反映できないという状況。
ちょっとしたことで直りそうな気がするのですが、今日は時間切れ。
仕方ないので、一旦できたところまでメモ。


# docker pull centos:7
# docker run -it --name nginxunit -p 8300:8300 --privileged centos:7 /sbin/init
# docker exec -it nginxunit /bin/bash
【ここからコンテナ上での操作】
# vi /etc/yum.repos.d/unit.repo
[unit]
name=unit repo
baseurl=https://packages.nginx.org/unit/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
# yum -y install unit
# yum -y install unit-php unit-python unit-go unit-perl
# systemctl enable unit.service
# systemctl start unit.service


# ps -ef | grep unit
root 189 1 0 12:46 ? 00:00:00 unit: main [/usr/sbin/unitd]
nobody 191 189 0 12:46 ? 00:00:00 unit: controller
nobody 192 189 0 12:46 ? 00:00:00 unit: router
root 194 59 0 12:46 ? 00:00:00 grep --color=auto unit


# systemctl status unit.service
● unit.service - NGINX Unit
Loaded: loaded (/usr/lib/systemd/system/unit.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2018-04-16 12:46:34 UTC; 1min 13s ago
(以下略)


# 設定の確認(初期設定)
# curl --unix-socket /var/run/control.unit.sock http://localhost/
{
"listeners": {},
"applications": {}
}


# PHP用の設定を作成する。
# pwd
/
# vi test.json
{
"listeners": {
"*:8300": {
"application": "test_php"
}
},

"applications": {
"test_php": {
"type": "php",
"processes": 20,
"root": "/var/www/html",
"index": "test.php"
}
}
}


# コンテンツ作成
# mkdir -p /var/www/html
# vi /var/www/html/test.php
(とりあえずphpinfo書いた)


# PHP用設定の反映(エラー)
# curl -X PUT -d /test.json --unix-socket /var/run/control.unit.sock http://localhost/
{
"error": "Invalid JSON.",
"detail": "A valid JSON value is expected here. It must be either a literal (null, true, or false), a number, a string (in double quotes \"\"), an array (with brackets []), or an object (with braces {}).",
"location": {
"offset": 0,
"line": 1,
"column": 1
}
}


(2018年4月17日追記)
こちらでコマンドを見直すことで、無事に動きました。


<戦利品>
WANTED GIRL(TrySail
aventure bleu(内田真礼
春が来てぼくら(UNISON SQUARE GARDEN