CentOS7 nginx 설치
"CentOS7에 nginx 설치하기"
---------------------------------------------------------------------------------------------------
* 테스트 환경
- CentOS7 + nginx 1.12.0
---------------------------------------------------------------------------------------------------
1. nginx 설치 전, epel 설치
# yum install epel-release |
- EPEL(Extra Packages of Enterprise Linux)는 리눅스 추가 패키지입니다.
- yum으로 설치가 안되는 것들이 많아서 epel을 설치해 도움을 받아야합니당
2. nginx 1.12.0 설치를 위해 nginx.repo 추가
# vim /etc/yum.repos.d/nginx.repo [nginx] name=nginx repobaseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1 |
3. nginx 설치
# yum install nginx |
4. nginx 시작 및 확인
- nginx 시작
# systemctl start nginx |
- nginx 시작이 잘 되었는지 확인
# systemctl status nginx |
5. 서버 부팅 시 자동실행 되도록 설정
# systemctl enable nginx |
6. nginx 실행
http://서버IP |
※ 만약!! 실행이 안된다면?!
1) SELinux 확인
- SELinux는 보안강화커널로 종종 SELinux 때문에 특정 서비스가 동작하지 않는다.
# cat /etc/sysconfig/selinux |
2) SELinux가 실행되고 있다면 해제하기
- 테스트이기 때문에 SELinux를 해제하는거예요! 실제 사용하신다면 특정 서비만 오픈시키거나 하셔야해요!
# vim /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled // enforcing -> disabled로 변경 # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted |
3) 방화벽 확인 (http, https 오픈 확인)
# firewall-cmd --list-service |
4) http, https 오픈하기
# firewall-cmd --permanent --zone=public --add-service=http # firewall-cmd --permanent --zone=public --add-service=https # firewall-cmd --reload |