본문 바로가기

프로젝트 & TIL/일별 공부 기록 (백엔드 스쿨)

32일차 - NginX, 방화벽, selinux, 도커

NginX 설치와 사용

yum install nginx : nginx 설치

systemctl status nginx : nginx 상태 보기 => inactive, disable 상태임

systemctl start nginx : 시작 => active 상태로 변경

systemctl restart nginx : 재부팅

systemctl stop nginx : 사용 중지 => inactive 상태로 변경

curl localhost => 접속이 안 된다.

systemctl enable nginx : enable 상태로 변경. 부팅 시 자동으로 켜짐

systemctl disable nginx : disable 상태로 변경. 부팅 시 자동으로 켜지지 않음

systemctl enable nginx => 다시 활성화

reboot now : PC 재부팅

curl localhost => 이제 접속이 된다.

방화벽 설정

systemctl status firewalld => 방화벽 상태 확인

systemctl stop firewalld => 방화벽 inactive

curl localhost => 접속됨

크롬에서 192.168~ 접속 => 페이지가 뜬다

systemctl stop nginx

크롬에서 192.168~ 접속 => 접속 안 됨

systemctl start nginx => 다시 크롬에서도 접속됨

systemctl disable firewalld => 방화벽 disable

selinux 끄기

getenforce : selinux 상태 확인

vim /etc/selinux/config > SELINUX=disabled 로 변경

    vim에서 undo : esc 누른 상태에서(메뉴 모드에서) u

    vim에서 redo : esc 누른 상태에서(메뉴 모드에서) ctrl + r

    vim에서 저장하지 않고 종료 : esc 누른 상태에서(메뉴 모드에서) :q!

setenforce 0 : 즉시 selinux 종료

getenforce => Enforcing에서 Permissive으로 바뀜

도커

# Uninstall old versions
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

# Set up the repository
yum install -y yum-utils

yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    
# Install Docker Engine
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# 도커 시작
systemctl start docker

# 도커 활성화
systemctl enable docker

# 도커 작동 테스트
docker run hello-world

이미지 == 프로그램

컨테이너 == 프로세스 == 가상 OS

  

데몬 컨테이너 / 일반 컨테이너