기왕 서버를 재 구축하게 된 김에 서버를 만드는 과정을 순서대로 적어보려고한다.
VIRTUAL BOX를 설치하고 이름, 용량, RAM, 코어 수, 네트워크 모드를 설정하고 우분투 ISO파일을 선택해서 서버를 설치한다.
편하게 사용하기 위해 한글을 등록해준다.
sudo apt update
sudo apt upgrade ibus-hangul
명령어로 IBUS 한글을 등록한뒤 설정- 언어에서 한글을 적용시키면된다.
ENGLISH는 해제해야 한영 전환이 쉽다.
sudo nano /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
enp0s3: # 본인의 네트워크 인터페이스 이름으로 변경
dhcp4: false
addresses:
172.30.x.x\/24
gateway4: 172.30.1.1
nameservers:
addresses:
8.8.8.8
8.8.4.4
이렇게 파일을 만들고 설정을 수정해준 다음
sudo netplan apply
ip addr show enp0s3
ping -c 4 google.com
주소를 할당받았는지 확인하고
인터넷이 되는지 ping테스트를 해본다.
ssh 설치 및 등록
sudo apt install openssh-server
update는 기본이니까 생략하겠다.
설치하고,
sudo systemctl status ssh
상태를 체크해본다.
sudo nano /etc/ssh/sshd_config
config파일에서
Port 22
AddressFamily any
ListenAddress 0.0.0.0
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
다음과같이 설정해주고
(22포트에, ipv4 and ipv6 수신, root 로그인 금지, 비밀번호 금지, pub pem키로 접속)
pem키를 서버와 로컬에 등록하고
ssh -i ~/.ssh/id_ed25519 -p 22 joo@x.x.x.x
접속하면된다.
github 등록하기
github 등록하기
ssh-keygen -t ed25519 -C "dudrknd1642@gmail.com"
cat ~/.ssh/id_ed25519.pub
ssh -T git@github.com
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io -y
docker --version
env, secretSSH 환경변수 설정하기
CICD 구축하기
ssl cert 도메인 인증하기
nginx 설정으로 도메인과 서버 연결하기
처음할때는 엄청 해메기도했지만
NAT모드를 먼저 해봐서 그런지 브리지모드는 어렵지 않게 끝냈다.
직접 2개를 다 해보니 이해가 다되서 쉬웠다.