-
Install: Confrirm the version.
-
make
% tar xzf nginx-1.9.2.tar.gz
% cd nginx-1.9.2
% ./configure \
--prefix=/usr/local \
--conf-path=/etc/nginx/nginx.conf
% make
% sudo make install
% brew update
% brew install nginx
# nginx.conf is here
# /usr/local/etc/nginx/nginx.conf
Operation | command | signal |
---|---|---|
Start | sudo nginx |
|
Finish | sudo nginx -s stop |
SIGTERM, SIGINT |
Quit(Graceful fini) | sudo nginx -s quit |
SIGQUIT |
Reload | sudo nginx -s reload |
SIGHUP |
- Confirm that the conf is OK
nginx -t
- Define HTTP server virtual host
server {
listen 80;
server_name www.example.com
}
- Process matched path with some conditions
location /event/ {
# DO SOMETHING
}
- Define content's directory
- It can be written in
http context
,server context
andlocation context
# http://www.example.com/ is root
location / {
root html;
}
# http:/www.example.com/html/ is root
location /html/ {
root html;
}
- URL for error page
error_page 404 @fallback;
location @fallback {
proxy_pass http://fallback_server;
}