1. yum 외부 저장소에 nginx.repo 파일 추가
기본 yum 저장소에는 nginx가 없기 때문에 외부 저장소에 추가 해야한다.
[root@localhost /]# cd etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo CentOS-fasttrack.repo microsoft-prod.repo
[root@localhost yum.repos.d]# vi nginx.repo
cd /etc/yum.repos.d/
- 해당 yum 저장소 경로로 이동
vi nginx.repo
- nginx.repo 파일 생성 후
i 로 입력을 활성화 한 후
아래 내용을 입력한다.
[nginx]
name=nginx repo
baseurl=https://nginx.org/packages/centos/$centosVersion/$basearch/
gpgcheck=0
enabled=1
SSL 보안 인증서 적용을 했다면 nginx baseurl에 https
기본 제일 처음 웹서버를 한다면 http로 바꾼 후 작성하고 저장한다.(ESC => :wq => Enter)
2. yum install
yum install 하여 nginx를 설치해 줍니다.
[root@localhost ~]# yum install -y nginx
3. 방화벽 포트 개방 혹은 클라우드 서비스 ACG 규칙 확인
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-ports
21/tcp 5000/tcp 5001/tcp 80/tcp
로컬 PC인 경우 방화벽 포트를 체크를 합니다.
클라우드 서비스(AWS, NCP 등)에서 직접 웹서버를 설치하고 배포를 한다고 하면
ACG 규칙에서 웹서버 배포 port를 개방해주세요.
4. Nginx 포트 설정
[root@localhost ~]# vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
nginx가 정상적으로 설치가 되었다면
vi /etc/nginx/conf.d/default.conf
명령어로 nginx default.conf를 열어서 내용을 확인한다.
listen에 본인이 원하는 port로 변경해준다.
servername은 localhost라고 되어있다면 본인의 URL을 그대로 쓴다느 뜻이고
도메인이 있다면 도메인을 입력해주면 된다.
쭉 따라왔다면 우리는 80 port를 열어주고 있다.
5. Nginx 배포
[root@localhost ~]# systemctl start nginx
systemctl start nginx (nginx 시작)
systemctl stop nginx (nginx 정지)
systemctl restart nginx (nginx 재시작)
systemctl status nginx (nginx 상태 체크)
6. Nginx 배포 확인
정상적으로 배포가 완료되었다면 아래 화면이 나올것이다.
아래 화면이 잘 나온다면 Nginx 배포 완료

localhost에 배포했다면
http://localhost:80
클라우드 및 서버 컴퓨터라면
http://본인URL
'Linux' 카테고리의 다른 글
| Wake On LAN (WOL) 설정 (0) | 2026.04.23 |
|---|---|
| Ubuntu Server 고정 IP 설정 (netplan) (1) | 2026.04.23 |
| SSH 원격 접속 설정 (0) | 2026.04.23 |
| Ubuntu Server 22.04 LTS 설치 방법 (CLI) (0) | 2026.04.23 |
| 남는 PC로 홈 서버 만들기 (0) | 2026.04.23 |