MAC 기준으로 설명하였습니다.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install nginx
brew services start nginx
brew services stop nginx
sudo service nginx restart
sudo service nginx reload
둘의 차이는 Nginx 재기동, restart vs reload 참고
document root 위치에 html 파일을 추가해야 한다.
일단 terminal에 다음과 같이 버전을 확인해보자
nginx -V
seungjo@Seungjos-MacBook-Air html % nginx -V
nginx version: nginx/1.25.3
built by clang 15.0.0 (clang-1500.0.40.1)
built with OpenSSL 3.1.3 19 Sep 2023
TLS SNI support enabled
configure arguments: --prefix=/opt/homebrew/Cellar/nginx/1.25.3 ...
nginx -V
를 입력하면 configure arguments가 나오는데 여기서 --prefix
를 확인해보자.
그러면, 각자의 환경에 따라 다르겠지만, 나의 경우에는 /opt/homebrew/Cellar/nginx/1.25.3
이다.
이제, /opt/homebrew/Cellar/nginx/1.25.3/
로 이동해서 ls -al
을 확인하면 다음과 같이 나올 것이다.
html directory
로 이동한 후 hello.html
을 다음과 같이 생성하였다.<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Hello</title>
</head>
<body>
<h1>hello nginx!</h1>
</body>
</html>