brunch

116. gcp 웹서버 만들기 - cli

by Master Seo


<1> Cloud Console에서 인스턴스 만들기


1. Console 왼쪽 상단 > Compute Engine > VM 인스턴스

디폴트 데비안으로 설치

Allow full access to all Cloud APIs

Allow HTTP trafficAllow HTTPS traffic

서버 생성완료

SSH를 클릭



2. NGINX 웹 서버 설치

sudo su -

# apt-get update


//NGINX 설치.

# apt-get install nginx -y


NGINX가 실행 중인지 확인합니다.

# ps -ef | grep nginx


공인 IP 확인 , 웹브라우저로 접속하기
접속 불가


vpc 네트워크 > 방화벽 허용

https://brunch.co.kr/@topasvga/855





<2> google cloud Shell


1. 오른쪽 상단 Cloud Shell 클릭


// 현재 설정 상태 확인하기

$ gcloud config list

[component_manager]

disable_update_check = True

[compute]

gce_metadata_read_timeout_sec = 5

[core]

account = topasvga@naver.com

disable_usage_reporting = True

project = seo-pj-277509

[metrics]

environment = devshell

Your active configuration is: [cloudshell-28992]


변경

gcloud config set compute/zone us-central1-a


변경

gcloud config set project www-serverchk-com


2. 계정 이름 목록을 표시할 수 있습니다.

$ gcloud auth list

Credentialed Accounts

ACTIVE ACCOUNT

* topasvga@naver.com

To set the active account, run:

$ gcloud config set account `ACCOUNT`



3. 다음 명령어로 프로젝트 ID 목록을 표시할 수 있습니다.

$ gcloud config list project

[core]

project = seo-pj-277509

Your active configuration is: [cloudshell-28992]


혹, 프로젝트가 나오지 않으면 consol에서 프로젝트를 선택하거나

명령어로 프로젝트를 지정해주면 된다.




<3> gcloud로 VM만들기


1. 초기 설정하기
gcloud init
초기 환경 확인 : https://brunch.co.kr/@topasvga/866

2. vm 만들기

gcloud compute instances create vm2 --machine-type n1-standard-2 --zone [your_zone]
gcloud compute instances create game-web01 --machine-type n1-standard-2 --zone asia-northeast1-a


// VM 인스턴스 확인

gcloud compute instances list


ssh키를 GCP에 미리 등록했다면 gcloud 명령어로 리눅스로 바로 로그인 된다.

ssh키 등록 https://brunch.co.kr/@topasvga/855


ssh로 접속하기

gcloud compute ssh game-web01 --zone asia-northeast1

y



감사 합니다.

keyword
매거진의 이전글115. 1) cloud shell,vm - cli