본문 바로가기

서버/Nginx

nginx basics

installation

docker pull nginx
docker container run -it -p 80:80 --name <container name> nginx bash

# or via any other ways appropriate to OS

verify installation

# version check
nginx -v

# running processes
ps -ef | grep nginx
# will give at least one master process and one worker process

# http request
curl localhost 
# will return a default index.html in `usr/share/html/`

folders and files

  • /etc/nginx/: default configuration root folder
  • /etc/nginx/nginx.conf: default configuration entry point that sets up global settings.
  • /etc/conf.d/:
    • contain HTTP server configuration file
    • .conf files in this folder are included in top-level http block of /etc/nginx/nginx.conf
    • Serve as same folder as site-enabled and site-available, which was deprecated.
  • /var/lib/nginx/: contain access.log and error.log
  • usr/share/html/: default virtual host folder
    root@6cc1a78f70a2:/usr/share/nginx/html$ tree
    .
    |-- 50x.html
    `-- index.html
  • recommended not to use for real sites but for testing purposes.

commands

nginx -h
nginx -v
nginx -V
nginx -t # test configuration
nginx -T # test configuration + print valicated configs.
nginx -s <stop|quit|reopen|reload> # send signal to master
  • An examplary chain of commands: modify configuration > nginx -t to verify > nginx -s reload

REFERENCES

  • NGINX Cookbook by Derek DeJonghe

'서버 > Nginx' 카테고리의 다른 글

Nginx Beginner’s Guide  (0) 2020.07.25
우분투 16.04 nginx 1.10 에서 1.16으로 업그레이드  (0) 2020.07.25