본문 바로가기

프론트엔드/리액트

Mac에서 nginx로 리액트 배포

 

1. Homebrew 설치: Homebrew는 Mac에서 패키지 관리자입니다. 터미널에서 다음 명령어를 실행하여 Homebrew를 설치합니다.

 

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

 

2. Nginx 설치: Homebrew를 사용하여 Nginx를 설치합니다. 터미널에서 다음 명령어를 실행합니다.

 

brew install nginx

 

3. Nginx 실행: Nginx를 실행하려면 다음 명령어를 입력합니다.

 

sudo nginx

 

 

 

sudo nginx -t        상태확인을 해보니까 내 nginx위치는

nginx: the configuration file /opt/homebrew/etc/nginx/nginx.conf syntax is ok

nginx: configuration file /opt/homebrew/etc/nginx/nginx.conf test is successful

 

 /opt/homebrew/etc/nginx/nginx.conf 이곳이 었고

 

sudo nano  /opt/homebrew/etc/nginx/nginx.conf  로 들어가서 수정해주었다.

 

server{

  listen 80;

  #server_name localhost;

 location / {

   root /Users/orange/Desktop/textile-frontend/bulid;

  index  index.html;

  try_files $uri &uri/  /index.html =404;

}

 

컨트롤+O 저장 enter 후 컨트롤+X

 

sudo nginx 실행하면 되야하는데 안 되는것은  파일이 권한이 없기때문

 

build찾아다가 ls-la해서  chmod 777 build 해주고 안되면 orange까지 해주고

 

재실행

ps -ef | grep nginx

 sudo kill -9 {pid}

 

죽이고 다시 sudo nginx

 

 

==================

ex: nginx 멈추는법

sudo nginx -s stop