NGINX 서버 띄우기

2021. 5. 21. 15:46카테고리 없음

NGINX 서버 띄우기

mac 기준

  • Brew 사용하여 Nginx 설치
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install nginx

nginx // nginx 구동

nginx -s stop // nginx 중지

nginx 명령어 입력 후, localhost:8080 입력

  • 기존 NGINX를 처음 시작시 localhost:8080에서 보여지는 화면
  • 사용자가 원하는 화면을 띄우기 위해 root 수정
  1. 설치된 nginx 디렉토리 이동
cd /usr/local/etc/nginx
  1. vim Editor로 nginx.conf 파일 수정
vi nginx.conf
  • nginx.conf 수정 화면
    • 본인이 띄우고 싶은 html파일의 경로를 location/ 내부에 작성해준다.
    • 기존에 작성돼있던 root는 # 로 주석 처리 해준다(#root html)
server {
    listen       8080;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
    #root   html;
            root /Users/imseonghu/NGINX;
        #index  index.html index.htm;
    }
  • NGINX 내부의 index.html 지정 -> 해당 index.html을 기존 NGINX root 대신 띄운다.
  • nginx.conf 파일 수정 후 nginx 중지 후 재 시동
nginx -s stop // 중지
nginx // 재시동