728x90
<NginX 웹서버 설치 방법>
1. nginx.repo 작성
[root@localhost ~]# cd /etc/yum./yum.repo.d
[root@localhost yum.repo.d]# vi nginx.repo
<vi 편집 내용>
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
2. nginx 서버 설치
[root@localhost ~]# dnf install nginx // nginx 설치
[root@localhost ~]# dnf info nginx // nginx 정보 확인
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl status nginx // active
[root@localhost ~]# nginx -t // nginx 문법 확인
[root@localhost ~]# nginx -v // 사용하고 있는 엔진엑스 버전 확인
[root@localhost ~]# systemctl enable nginx // 브이엠웨어를 껐다 켜도 자동으로 엔진엑스가 실행
- 브라우저에서 홈페이지 접속이 안 될 시, 방화벽과 Selinux 보안 확인
1. 방화벽 내리기
[root@localhost ~]# firewall-cmd --permanent --add-service=http // http에 대한 서비스 추가
[root@localhost ~]# firewall-cmd --permanent --list-all // 설정 확인
[root@localhost ~]# firewall-cmd --reload // 리부팅
2. Selinux 보안 끄기
[root@localhost ~]# vi /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
# 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
>> 여섯번째 줄, SELINUX=disabled으로 변경 후 reboot
<엔진엑스 서버 설정>
- default.conf 파일 설정 (위치: /etc/nginx/conf.d/default.conf)
- index.html 설정
1. default.conf
<편집 내용>
server {
listen 80;
server_name 192.168.111.128;
location / {
root /home/centos/html.128; >> 이 위치에 index.html 파일이 있음
index index.html index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
2. index.html (기본 양식)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
3. 엔진엑스 서비스 재가동
[root@localhost ~]# systemctl restart nginx
<웹 서버 가동 확인>
1. 브라우저 접속 (서버 ip 입력)
2. curl + ip 주소
'Web Server' 카테고리의 다른 글
CentOS8에서 NginX를 이용해 NFS 서버 구축 (0) | 2024.01.31 |
---|---|
CentOS8에서 NginX 네임서버 DNS와 부하분산 설정 (2) (0) | 2024.01.30 |
CentOS8에서 NginX 네임서버 DNS와 부하분산 설정 (1) (0) | 2024.01.28 |
웹서버 개요 이론 :: Apach 아파치 vs Nginx 엔진엑스 (1) | 2024.01.27 |
정적 웹 페이지와 동적 웹 페이지란? (1) | 2023.12.06 |