21.11.27 Bash shell 에서 React 배포

2021. 11. 27. 20:33작업/git

내가 만든 사이트 도메인 : elice-kdt-3rd-vm-091.koreacentral.cloudapp.azure.com

(7일짜리라서 7일 뒤에 사라짐)

 

$ ssh {엘리스에서 준 ID}@{엘리스에서 받은 도메인}

$ password : {엘리스에서 준 비밀번호 입력}

 

$ sudo apt-get update #우분투에서 프로그램을 다운받는 프로그램

$ sudo apt-get install -y build-essential

$ sudo apt-get install curl

$ curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

$ sudo apt-get install -y node.js

 

$ sudo npm install -g yarn

$ sudo apt-get install git-core

 

$ git init $ git remote add origin {자기 gitlab 주소}

$ git pull origin master # -> 자기 id, password를 입력하면 pull이 진행된다

 

$ npm install package.json -> node_modules 만드는 작업

 

# npm 사용중이라면

$ npm run-script build or

(#yarn 사용중이라면

$ yarn build)

 

$ sudo apt install nginx

 

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /home/{엘리스에서 받은 ID}/build;

        # Add index.php to the list if you are using PHP
        index index.html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.html;

# 저장하고 파일에서 나오려면 ctrl+C 눌러주고 아래 명령어 + 엔터

:wq

# 그냥 나오기 아래 명령어 + 엔터

:qa

 

$ sudo service nginx restart

 

 

배포 후 업데이트

 

$ git pull origin master

 

$ rm -r build # $ rm -r [디렉토리명] --> 우분투 디렉토리 삭제 명령어 하위 파일까지 모두 삭제

 

# npm 사용중이라면

$ npm run-script build 또는

#yarn 사용중이라면

$ yarn build

 

$ nginx -s reload -> nginx 재가동

 

$ sudo service nginx restart -> nginx 재시작

 

출처 민영님 노션

https://scented-saver-c2a.notion.site/mac-ea6cc294f9d242768bd04d7f16ef4fed#b772ffc616c4467a9dddca6afc848906

 

배포 (mac 기준)

주의사항 - 아래에 예를들어 {엘리스에서 준 ID} 라고 써있는 경우, {} 는 제외하고 내용물만 작성해줍니다. - 터미널 기본 명령어 $ls - 현재 디렉토리 파일 목록 확인 $cd - 디렉토리로 이동

scented-saver-c2a.notion.site