빠른 시작(Quick Start)
Unit에서 애플리케이션을 실행하려면 먼저 application 객체를 설정합니다. 여기에서 파일에 저장하여 http://localhost/
의 제어 소켓을 통해 사용할 수 있는 Unit의 제어 API의 config/applications
섹션에 PUT
합니다.
$ cat << EOF > config.json
{
"type": "php",
"root": "/www/blogs/scripts"
}
EOF
# curl -X PUT --data-binary @config.json --unix-socket \
/path/to/control.unit.sock http://localhost/config/applications/blogs
{
"success": "Reconfiguration done."
}
Unit이 Start 절차를 시작합니다. 다음으로 API의 config/listeners
섹션에서 IP(또는 임의의 IP와 일치하는 와일드카드) 및 포트 번호를 포함하는 Listener 객체에서 애플리케이션 객체를 참조합니다.
$ cat << EOF > config.json
{
"pass": "applications/blogs"
}
EOF
# curl -X PUT --data-binary @config.json --unix-socket \
/path/to/control.unit.sock http://localhost/config/listeners/127.0.0.1:8300
{
"success": "Reconfiguration done."
}
Unit은 지정된 IP 및 Port에서 요청을 수락하여 Application Process에 전달합니다. 앱(App)이 작동합니다!
마지막으로 결과 구성을 확인합니다.
# curl --unix-socket /path/to/control.unit.sock http://localhost/config/
{
"listeners": {
"127.0.0.1:8300": {
"pass": "applications/blogs"
}
},
"applications": {
"blogs": {
"type": "php",
"root": "/www/blogs/scripts/"
}
}
}
전체 구성(Configuration)을 한 번에 업로드하거나 부분적으로 업데이트할 수 있습니다.