초기 셋팅

앞으로 centos7 VM을 설정하면 이렇게 3개의 초기 셋팅하기!

1. 방화벽 off

[root@web ~]# systemctl stop firewalld
[root@web ~]# systemctl disable firewalld

2. 셀리눅스 off

# SElinux

셀리눅스가 활성화 되어있으면, 나중에 DNS나 KVM을 구성할때 문제가 발생할 수 있음.

앞으로 항상 방화벽과 셀리눅스는 비활성화를 하고 진행

# 셀리눅스 켜진 상태
# 임시 비활성 상태

# 1. 파일 안들어가기
[root@web ~]# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config

# 2. 파일 들어가기
[root@web ~]# vi /etc/selinux/config

# 설정파일

# enforcing을 disabled로 수정

[root@web ~]# systemctl restart network
[root@web ~]# reboot

# 재부팅 후에 비활성화가 된걸 확인

3. 레포지토리

- 설치하고 싶은 패키지가 있는 저장공간

- 패키지가 책이라면, 레포지토리는 책장!

cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

EOF

# 앞으로는 centos7을 설치하고 패키지를 다운받고 싶다면 단순히 위 내용을 복붙하는것만으로도 해결 가능

 

ggdG

# vi 편집기 명령모드에서 입력하면 전체 삭제

# yum 같은 패키지관리자로 install을 하면, 기본적으로 위 디렉토리에 있는 모든 레포파일을 읽어들일 수 있다.

[root@web ~]# cd /etc/yum.repos.d/
[root@web yum.repos.d]# vi CentOS-Base.repo

# enabled라는 항목이 없으면 기본적으로 활성화된 레포

# enabled=0이면 비활성화

# repolist = 활성화된 레포지토리들.


# 명령어가 없으니 설치

[root@web yum.repos.d]# yum install -y net-tools

# ifconfig 명령이 들어있는 패키지 설치

# xshell 복붙할때 안물어보게

# EOF(End Of File, 언제 입력을 끝낼지 결정하는 단어, 맘대로 정할 수 있음)

# EOF가 나오기 전까지 입력된 여러줄의 내용을 파일에 리다이렉션

# << : 표준입력

# > : 표준출력을 덮어쓰기


정적 웹서버

[root@web yum.repos.d]# yum install -y httpd

# apache 설치

root@web yum.repos.d]# systemctl restart httpd
[root@web yum.repos.d]# systemctl enable httpd

# 즉시 동작 및 재부팅 후에도 동작하도록